I have a model in which out of numerous amounts of curves in the work space, I only want four. So i have curve 1 and cyrve 2 on mesh A, and curve 3 and curve 4 on mesh B. I will do meshintersect+splitmeshwithcurve+deletemeshface, hope that makes sense. Now i am working on a script in which rhino can detect curve 1 and 2 are on mesh A, and perform the intersection etc and this continues on with mesh B.
I originally secluded them by length but each model has different lengths and even range varies, so its not repeatable. SO for now i have settled on selecting these four curves out of the work space using get object and then performing the necessary tasks. BUT of course this is not preferred. Someone gave me advice on using coordinates ( creating bboxes round each curve, finding the centroid and then using either the x y or z coordinates to select the curves) but thats a bit of work for me, although im still looking into it. But for now this get object script i have keeps crashing Rhino, it works at times, and crashes most of the time. can someone check what exactly is wrong with it?
SCRIPT >>>
from Rhino.Commands import Result
from Rhino.DocObjects import ObjectType
import rhinoscriptsyntax as rs
from scriptcontext import doc
bfcrv_id = rs.GetObjects(“Select bf curves”,4)
if bfcrv_id:
#create an empty list
bfcurve=[]
for obj in bfcrv_id:
#find curves among the objects
if abs(rs.CurveLength(obj)<100):
#curve meets selection criteria, append to the list
bfcurve.append(obj)
ffcrv_id = rs.GetObjects(“Select ff curves”,4)
if ffcrv_id:
#create an empty list
ffcurve=[]
for obj in ffcrv_id:
#find curves among the objects
if abs(rs.CurveLength(obj)<100):
#curve meets selection criteria, append to the list
ffcurve.append(obj)
rs.UnselectAllObjects()
target=500
back_objs=rs.ObjectsByLayer(“3.08 Back Face Surface”)
if back_objs:
braces=[]
for obj in back_objs:
if rs.IsMesh(obj):
if abs(rs.MeshQuadCount(obj)>=target):
braces.append(obj)
#get a list of all objects on the layer you want
front_objs=rs.ObjectsByLayer(“3.07 Front Face Surface”)
if front_objs:
faces=[]
for obj in front_objs:
if rs.IsMesh(obj):
if abs(rs.MeshQuadCount(obj)>target):
faces.append(obj)
Split mesh with curve
rs.Command("-_SplitMeshWithCurve selid “+str(braces[0])+” selid “+str(bfcurve[0]))
rs.Command(”-_SplitMeshWithCurve selid “+str(braces[0])+” selid “+str(bfcurve[1]))
rs.Command(”-_SplitMeshWithCurve selid “+str(faces[0])+” selid “+str(ffcurve[0]))
rs.Command(”-_SplitMeshWithCurve selid “+str(faces[0])+” selid "+str(ffcurve[1]))
delete smaller meshes
sm=500
layer4_objs=rs.ObjectsByType(32,select=False)
if layer4_objs:
fourmesh=[]
for obj in layer4_objs:
if rs.IsMesh(obj):
if abs(rs.MeshQuadCount(obj)<sm):
fourmesh.append(obj)
rs.DeleteObjects(fourmesh)