Created
May 9, 2012 10:58
-
-
Save bengolder/2643722 to your computer and use it in GitHub Desktop.
RhinoPython: Convert Elevation Text Objects to 3d Points
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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