-
Notifications
You must be signed in to change notification settings - Fork 2
/
AddBlockName.py
32 lines (25 loc) · 941 Bytes
/
AddBlockName.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
import rhinoscriptsyntax as rs
def AddBlockName(obj):
name = rs.BlockInstanceName(obj)
pt = rs.BlockInstanceInsertPoint(obj)
bb=rs.BoundingBox(obj)
text=rs.AddText(name,(bb[0]+bb[6])/2)
rs.SetUserText(text, 'tag', 'label')
group=rs.AddGroup()
rs.AddObjectsToGroup([obj, text], group)
objs=rs.GetObjects("Select objects to label", rs.filter.instance, preselect=True)
if objs:
map(AddBlockName, objs)
# def AddNameLayerGroupObj():
# objs=rs.GetObjects("Select objects to label",4+8+16,preselect=True)
# if not objs: return
# for obj in objs:
# name=rs.ObjectName(obj)
# if not name: name="None"
# layer=rs.ObjectLayer(obj)
# bb=rs.BoundingBox(obj)
# text="Name: {}\nLayer: {}".format(name,layer)
# dot=rs.AddTextDot(text,(bb[0]+bb[6])/2)
# group=rs.AddGroup()
# rs.AddObjectsToGroup([obj,dot],group)
# AddNameLayerGroupObj()