-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathextractmassfromblk.py
More file actions
45 lines (31 loc) · 1.27 KB
/
extractmassfromblk.py
File metadata and controls
45 lines (31 loc) · 1.27 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
import rhinoscriptsyntax as rs
import trkRhinoPy as trp
import scriptcontext as sc
import Rhino
# import Rhino as rc
# sc.doc = rc.RhinoDoc.ActiveDoc
# levels = sc.sticky["lvldict"]
blkids = rs.GetObjects('select objects', rs.filter.instance, preselect=True)
rs.EnableRedraw(False)
rs.UnselectAllObjects()
masses = []
def blkObjs(blkid):
blockName = rs.BlockInstanceName(blkid)
# objref = rs.coercerhinoobject(blkid)
# idef = objref.InstanceDefinition
# idefIndex = idef.Index
# lvl = levels[rs.GetUserText(blkid, 'level')]
# height = lvl['height']
xform = rs.BlockInstanceXform(blkid)
# objects = [x for x in rs.BlockObjects(blockName) if 'mass' in rs.ObjectLayer(x)]
objects = filter(lambda x: 'mass' in rs.ObjectLayer(x), rs.BlockObjects(blockName))
# objects = filter(lambda x: 'mass' in rs.ObjectLayer(x) and rs.GetUserText(x, 'class') != 'na', rs.BlockObjects(blockName))
# objects = map(lambda x: rs.SetUserText(x, 'level', lvl), objects)
# map(lambda x: rs.SetUserText(x, 'height', lvl))
blockInstanceObjects = rs.TransformObjects(objects, xform, True)
masses.extend(blockInstanceObjects)
map(blkObjs, blkids)
# masses = map(massFromSrf, objs)
rs.SelectObjects(masses)
rs.EnableRedraw(True)