Archiologics

Studio archiologics is a design think tank moved by the need of innovative thinking in architecture.We believe that complex, integrative thinking leads to a complex architecture which can be solved through simple methodologies and analytic algorithmic procedures.


ABOUTSERVICESARTICLESCONTACT

Surface Subdivision in RhinoPython - Studio Archiologics
Algorithmic design & BIM consultancy
Archiologics, algorithmic design, BIM consultancy, architecture studio, architectural design, architectural projects, phyton
21037
post-template-default,single,single-post,postid-21037,single-format-standard,cookies-not-set,ajax_updown_fade,page_not_loaded,qode-page-loading-effect-enabled,,qode_grid_1200,side_menu_slide_from_right,footer_responsive_adv,transparent_content,qode-theme-ver-16.9,qode-theme-bridge,qode_advanced_footer_responsive_1000,wpb-js-composer js-comp-ver-5.5.2,vc_responsive

Surface Subdivision in RhinoPython

Surface Subdivision in RhinoPython

Surface Subdivision in RhinoPython

This generates a subdivision based on any 4-corner surface and names the panels. It also creates tabs, should you want to unroll it for fabrication. The panels are, in addition, named for reference.

 

#script written by Adolfo Nadal

#import rhinoscriptcontext

import rhinoscriptsyntax as rss

 

#calculate the normal on the surface with a given scalefactor

def calcNormalWithSize(srf,uParam,vParam,size,ptBase):

ptNorm = rss.SurfaceNormal(srf,(uParam,vParam))

ptNorm = rss.VectorScale(ptNorm,size)

ptNorm = rss.VectorAdd(ptNorm,ptBase)

return ptNorm

 

#get surface from user: filter 8 for surfaces

srf = rss.GetObject(“Please select a surface”,8)

 

#get a series of subdivisions

divU = rss.GetInteger(“Please enter number of subdivisions in U direction”,5,2,100)

divV = rss.GetInteger(“Please enter number of subdivisions in V direction”,5,2,100)

 

#enter your desired tab size

tabSize = rss.GetReal(“Please enter tab size”,2,0.1,10)

 

#populate the surface with points

#-surface domain

domU = rss.SurfaceDomain(srf,0)

domV = rss.SurfaceDomain(srf,1)

 

print (domU)

print (domV)

 

#enter variables that contain surface domain

#max will be the second value, therefore [1]

domUMax = domU[1]

domUMin = domU[0]

domVMax = domV[1]

domVMin = domV[0]

 

#calculate the stepSize

stepU = (domUMax-domUMin)/divU

stepV = (domVMax-domVMin)/divV

 

rss.EnableRedraw(False)

 

counter = 0

#create points on surface

for i in range(divU+1):

for j in range(divV+1):

if((i>0)and(j>0)):

#-evaluate surface

uParam = i*stepU

vParam = j*stepV

pt1Coord = rss.EvaluateSurface(srf,uParam,vParam)

pt2Coord = rss.EvaluateSurface(srf,uParam-stepU,vParam)

pt3Coord = rss.EvaluateSurface(srf,uParam-stepU,vParam-stepV)

pt4Coord = rss.EvaluateSurface(srf,uParam,vParam-stepV)

 

#obtain middle points

ptMid12Coord = rss.EvaluateSurface(srf,uParam-stepU/2,vParam)

ptMid23Coord = rss.EvaluateSurface(srf,uParam-stepU,vParam-stepV/2)

ptMid34Coord = rss.EvaluateSurface(srf,uParam-stepU/2,vParam-stepV)

ptMid41Coord = rss.EvaluateSurface(srf,uParam,vParam-stepV/2)

 

#add the point on the surface

#pt = rss.AddPoint(ptCoord)

#add components to the surface

polyPt = (pt1Coord,pt2Coord,pt3Coord,pt4Coord,pt1Coord)

#poly = rss.AddPolyline(polyPt)

 

#Add segments ON the surface

crv1 = rss.AddInterpCrvOnSrf(srf,(pt1Coord,pt2Coord))

crv2 = rss.AddInterpCrvOnSrf(srf,(pt2Coord,pt3Coord))

crv3 = rss.AddInterpCrvOnSrf(srf,(pt3Coord,pt4Coord))

crv4 = rss.AddInterpCrvOnSrf(srf,(pt4Coord,pt1Coord))

 

#join curve segments into one and delete segments (true)

crvs = (crv1,crv2,crv3,crv4)

joinCrv = rss.JoinCurves(crvs,True)

 

#calculate normals!!!

#beware, vectors in rhino are by default 0-based (0,0,0)

#1st calculate normal

#2nd scale (if desired)

#3rd move (by adding)

ptN1Coord = calcNormalWithSize(srf,uParam,vParam,tabSize,pt1Coord)

ptMidN12Coord = calcNormalWithSize(srf,uParam-stepU/2,vParam,tabSize,ptMid12Coord)

ptMidN23Coord = calcNormalWithSize(srf,uParam-stepU,vParam-stepV/2,tabSize,ptMid23Coord)

ptMidN34Coord = calcNormalWithSize(srf,uParam-stepU/2,vParam-stepV,tabSize,ptMid34Coord)

ptMidN41Coord = calcNormalWithSize(srf,uParam,vParam-stepV/2,tabSize,ptMid41Coord)

 

#verify that it works

#rss.AddPoint(ptMidN12Coord)

#rss.AddPoint(ptMidN23Coord)

#rss.AddPoint(ptMidN41Coord)

 

#visualize normal

#rss.AddLine(pt1Coord,ptN1Coord)

#add tabs to the model

triaTab1Pts = (pt1Coord,pt2Coord,ptMidN12Coord)

triaTab2Pts = (pt2Coord,pt3Coord,ptMidN23Coord)

triaTab3Pts = (pt3Coord,pt4Coord,ptMidN34Coord)

triaTab4Pts = (pt4Coord,pt1Coord,ptMidN41Coord)

 

tab1Srf = rss.AddSrfPt(triaTab1Pts)

tab2Srf = rss.AddSrfPt(triaTab2Pts)

tab3Srf = rss.AddSrfPt(triaTab3Pts)

tab4Srf = rss.AddSrfPt(triaTab4Pts)

 

basePts = (pt1Coord,pt2Coord,pt3Coord,pt4Coord)

baseSrf = rss.AddSrfPt(basePts)

 

#join to create a single polysurface object

srfs = (tab1Srf,tab2Srf,tab3Srf,tab4Srf,baseSrf)

basePolySrf = rss.JoinSurfaces(srfs,True)

 

rss.ObjectColor(basePolySrf,(2*i*j,0,255-2*(i*j)))

 

ptCtCoord = rss.EvaluateSurface(srf,uParam-stepU/2,vParam-stepV/2)

rss.AddTextDot(counter,ptCtCoord)

counter = counter +1

#rss.AddPoint(ptN1Coord)

#create panels

 

rss.EnableRedraw(True)

 

No Comments

Post A Comment

Send this to a friend