Hi,
I have a basic code by which im trying to get the center of a number of curves without them sitting on a cplane.
However im currently doing this for each curve in the list manually, i rather just loop it to apply the code to each curve in a list, and then print out the centroid.
I also need to be able to use this centroid values to select specific curves from these lists. Not sure how to go about it, help is so appreciated. My code is down below:
from Rhino.Commands import Result
from Rhino.DocObjects import ObjectType
import rhinoscriptsyntax as rs
from scriptcontext import doc
layer_objs = rs.ObjectsByType(4,True)
if layer_objs:
#create an empty list
mylist=[]
for obj in layer_objs:
#find curves among the objects
if rs.IsCurve(obj):
if abs(rs.CurveLength(obj)<100):
#curve meets selection criteria, append to “good” list
mylist.append(obj)
rs.UnselectAllObjects()
#CURVE1
#rs.UnselectAllObjects()
rs.SelectObjects(mylist[0])
bBox = rs.BoundingBox(mylist[0])
cent = [(bBox[0][0] + bBox[6][0])/2,(bBox[0][1] + bBox[6][1])/2,(bBox[0][2] + bBox[6][2])/2]
print cent
rs.AddPoint(cent[0],cent[1],cent[2])