Answers:
-
For quick things such as this I just usually print things to see what they are.
-
As Helvetosaur said, you don’t get a guid until they are added to the document. I think understanding how to transition from doc to geometry (rhinocommon) and back is one of the trickiest aspects of working with Python and Rhino. Generally, the rhinoscript functions work with guids, and they kind of hide the geometry parts. A good way to learn about it is to look at the rhinoscript source and see what they do.
I rarely use rhinoscript to do any geometry calculations or generation. I use it quite a bit for input/interaction and coercion down to the geometry layer, but then I stay there until done, then bring back what I want into the document.
Back to your questions though:
The lines are showing up because they are being added to the doc in the drawline function:
def drawline(x1,y1,z1,x2,y2,z2):
pt1 = (x1,y1,z1)
pt2 = (x2,y2,z2)
if pt1 == pt2:
rs.MessageBox("Line ends are equal: " + str(x) +", "+ str(y) +", "+ str(z) )
guid = None
else:
guid = rs.AddLine( pt1, pt2) <- this adds the lines to the document
return guid
Like Helvetosaur said, you probably want to use ‘virtual’ lines here and return the geometry, something like (untested):
def make_line(x1, y1, z1, x2, y2, z2):
start = Rhino.Geometry.Point3d(x1, y1, z1)
end = Rhino.Geometry.Point3d(x2, y2, z2)
line = Rhino.Geometry.LineCurve(start, end)
return line
For the message box, get the guid(s) when you add them to the doc here:
doc.Objects.AddCurve(fillet_curve[0])
This returns the guid:
And return them. If you want all 3 pieces of the fillet, then you have to process the returned list of curves.
I haven’t done much filleting in code so I explored the CreateFilletCurves function a little:
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
# get some curves
guid1 = rs.GetObject('curve 1')
guid2 = rs.GetObject('curve 2')
# check
print (guid1, guid2)
# get curve geo
geo1 = rs.coercegeometry(guid1)
geo2 = rs.coercegeometry(guid2)
# check
print (geo1, geo2)
# get points on curves
geo1_point = geo1.PointAtNormalizedLength(1.0)
geo2_point = geo2.PointAtNormalizedLength(0.0)
# check
print (geo1_point)
print (geo2_point)
# add points to doc to see if they are on the correct sides of the curves
sc.doc.Objects.AddPoint(geo1_point)
sc.doc.Objects.AddPoint(geo2_point)
# try the CreateFilletCurves function with hard coded radius
fillet_curve_array = Rhino.Geometry.Curve.CreateFilletCurves(geo1,
geo1_point,
geo2,
geo2_point,
2,
False,
True,
True,
sc.doc.ModelAbsoluteTolerance,
sc.doc.ModelAngleToleranceDegrees
)
# check what it gives you
print(fillet_curve_array)
# add cuves to doc, keeping their returned guids
guids = []
for c in fillet_curve_array:
curve_guid = sc.doc.Objects.AddCurve(c)
guids.append(curve_guid)
# print the guids
print(guids)
Changing the Join param and Boolean seemed to work as expected. Join=False, Boolean=True example:
Which I think is what you are after?