Rickson
(Rickson)
12
def CSVBom():
listA = _csv
#a = listA
plane=Rhino.Geometry.Plane.WorldXY
ListTotals = []
table = _pointFeed
rs.EnableRedraw(False)
ListLarge = []
ListLen = []
a=0
for row in listA:
row = row.split(";")
rowA = []
for str in row:
str = str.replace("\n","")
rowA.append(str)
rowB = []
for aa in rowA:
rowB=aa.split(',')
if len(rowB)<= len(rowA):rowB=rowA
list=[]
A=len(rowB)
ListLen.append(A)
for txt in rowB:
if txt :
test = rs.AddText(txt, plane, height=_textSize, font='Arial', font_style=0, justification=None)
bb = rs.BoundingBox(test, plane, in_world_coords=True)
if bb :
large =round(( bb[1].DistanceTo(bb[0])),1)
if large < 0: largeur=large*(-1)
list.append(large)
rs.DeleteObject(test)
else :
large=0.0
list.append(large)
else :
large=0.0
list.append(large)
ListLarge.append(list)
N = max(ListLen)
d_max = {i: max(map(itemgetter(i), ListLarge)) for i in range(N)}
#Largest
ListMax = d_max.values()
#Layers
rs.AddLayer("Name")
rs.AddLayer("Detail Lines",parent="Name")
rs.AddLayer("Texts",parent="Name")
listB = _csv
Group=rs.AddGroup()
ListGroup = []
H = _textSize
font='Arial'
count=1
for row in listB:
V=0
Y=0
row = row.split(";")
rowA = []
for str in row:
str = str.replace("\n","")
rowA.append(str)
rowB = []
for aa in rowA:
rowB=aa.split(',')
if len(rowB)<= len(rowA):rowB=rowA
for value in rowB:
#text placement
placeA= ((-H*2) - (float(count)*(H*2)))
placeB= ((-H) - (float(count)*(H*2)))
#rectangle
LX = (ListMax[Y])+(H*.25+H)
recA=rs.AddRectangle(plane,LX,H*2)
VV=V+(LX/2)
recA=rs.MoveObject(recA,[V,placeA,0.0])
rs.ObjectLayer(recA,"Detail Lines")
ListGroup.append(recA)
#text
txt=value
if txt :
txtA=rs.AddText (txt,plane,H,font,0,2 + 131072)
txtA=rs.MoveObject(txtA,[VV,placeB,0.0])
rs.ObjectLayer(txtA,"Texts")
ListGroup.append(txtA)
#new text placement
Y=Y+1
V=V+LX
#New Line
count=count+1
ListGroup=rs.MoveObjects(ListGroup,table)
# rs.EnableRedraw(True)
rs.AddObjectsToGroup(ListGroup,Group)
if x:
CSVBom()