forked from tkahng/trkRhinoPython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
outputmass.py
33 lines (24 loc) · 807 Bytes
/
outputmass.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
import rhinoscriptsyntax as rs
import trkRhinoPy as trp
import scriptcontext as sc
# import Rhino as rc
# sc.doc = rc.RhinoDoc.ActiveDoc
levels = sc.sticky["lvldict"]
objs = rs.GetObjects('select objects', rs.filter.surface|rs.filter.polysurface, preselect=True)
rs.EnableRedraw(False)
def massFromSrf(obj):
lvl = levels[rs.GetUserText(obj, 'level')]
height = float(lvl['height'])
startpt = trp.objBBPts(obj)[0]
endpt = (startpt.X, startpt.Y, startpt.Z + height)
curve = rs.AddLine(startpt, endpt)
mass = rs.ExtrudeSurface(obj, curve)
trp.copySourceLayer(mass, obj)
trp.copySourceData(mass, obj)
rs.DeleteObject(curve)
return mass
rs.UnselectAllObjects()
masses = map(massFromSrf, objs)
rs.SelectObjects(masses)
rs.EnableRedraw(True)