I’m trying to create a script that will allow me to select some curves, 1 or more, and run a pipe command on them with dialog boxes that give options for tubing diameter and wall thickness. I’m having trouble getting the script to just run the pipe command on curves one after another. Getting guid issues, which I thought I could fix by using coercecurve to translate the guid to an actual curve:
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
def createTube():
unitSystem = rs.UnitSystem()
tol=sc.doc.ModelAbsoluteTolerance
aTol=sc.doc.ModelAngleToleranceRadians
crvID = rs.GetObjects("Choose Curves to Create Tubing From", 4, rs.filter.curve, preselect=True)
# Tubing Parameters
tubeDiameter = ["2.0", "1.875", "1.75", "1.675", "1.5", "1.25", "1.0", "0.875", "0.75", "0.675", "0.5"]
wallThickness = ["0.035", "0.049", "0.065", "0.083", "0.095", "0.120", "0.156", "0.188", "0.250"]
tubeDiameter = rs.ListBox(tubeDiameter, "Choose Tube Diameter", default = "2.0", title = "DOM Tubing")
wallThickness = rs.ListBox(wallThickness, "Choose Wall Thickness", default = "0.095", title = "DOM Tubing")
tubeDiameterIndex = tubeDiameter.index(tubeDiameter)
wallThicknessIndex = wallThickness.index(wallThickness)
for crv in crvID:
curve = rs.coercecurve(crv)
rs.UnselectAllObjects()
rs.SelectObject(curve)
layer = rs.ObjectLayer(curve)
Rhino.Geometry.Brep.CreatePipe(curve,(0.0,1.0),(tubeDiameterIndex,tubeDiameterIndex),True,0,False,tol,aTol)
print "Tubes Created"
createTube()
I’m sure I have messed the script up royally by now trying to fix it, but any tips on how to do this more efficiently would be appreciated. Thank you.
Carl