Skip to content

Instantly share code, notes, and snippets.

@bengolder
Created May 9, 2012 10:58
Show Gist options
  • Save bengolder/2643722 to your computer and use it in GitHub Desktop.
Save bengolder/2643722 to your computer and use it in GitHub Desktop.
RhinoPython: Convert Elevation Text Objects to 3d Points
import scriptcontext
import Rhino
def getLayerGeometry(layerName, typefilter=Rhino.DocObjects.TextObject):
'''uses doc.Objects.FindByLayer and returns the Geometry of the
resulting RhinoObjects. If nothing found, returns an empty list.'''
objs = scriptcontext.doc.Objects.FindByLayer(layerName)
out = []
for obj in objs:
if isinstance(obj, typefilter):
out.append(obj)
return out
def getText(textObject):
txt = textObject.DisplayText
if ',' in txt:
txt = txt.replace(',', '.')
return float(txt)
def moveText(tObj):
z = getText(tObj)
geom = tObj.Geometry
geom.Translate(0.0,2.0,z)
plane = geom.Plane
scriptcontext.doc.Objects.AddPoint(plane.Origin)
objects = getLayerGeometry('O_COTA_EDIFICI')
#moveText(objects[0])
for obj in objects:
moveText(obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment