Hi, i am trying to select a surface into a brep and obtain a offsetcurveonsurface metod.
This code is a copypaste of all the piece that i found useful but i realy cannot understand how rhinoscriptsintax.offsectcurveonsurface() work.
Thanks in advance
import rhinoscriptsyntax as rs
def TestOffset():
curve = rs.GetEdgeCurves("dammi le curve")
if curve is None: return False
curve = rs.JoinCurves(
reference = SubObjectSelect()
surface = reference[0]
point = reference[1]
if surface is None: return False
point = reference[1]
if point is None: return False
parameter = 4
rc = rs.OffsetCurveOnSurface( curve, surface, parameter )
return rc is not None
def SubObjectSelect():
obj_ref = rs.GetObject(message="Bla", filter=8, preselect=False, subobjects=True)
if obj_ref:
return [obj_ref.Surface(),obj_ref.SelectionPoint()]
print "Surface:", obj_ref.Surface()
print "Selection Point:", obj_ref.SelectionPoint()
TestOffset()
Hello - - GetEdgeCurves() returns a bunch of information including ids and pick locations - JoinCurves() wants a list of curve ids only. So you’ll need to pick through the info in your variable ‘curve’ to find the relevant ids of the curves.
for example:
crvs = [curve[n][0] for n in range(len(curve))]
Then Join them
newCurve = rs.JoinCurves(crvs,True)[0]
JoinCurves returns a list - that is a bunch of curves will not necessarily join into one curve. The above takes the first item in the list.
The variable ‘parameter’ should really be ‘distance’ and should be offered twice, I would say, once positive and once negative since the offset direction may fail one way and need to be tried again the other. (See the Help on OffsetCurveOnSurface()
import rhinoscriptsyntax as rs
def TestOffset():
curve = rs.GetEdgeCurves("dammi le curve")
if curve is None: return False
crvs = [curve[n][0] for n in range(len(curve))]
newCurve = rs.JoinCurves(crvs,True)[0]
reference = SubObjectSelect()
surface = reference[0]
point = reference[1]
if surface is None: return False
point = reference[1]
if point is None: return False
distance = 4
offset = rs.OffsetCurveOnSurface( newCurve, surface, distance )
if not offset: rs.OffsetCurveOnSurface( newCurve, surface, -1*distance )
return offset
def SubObjectSelect():
obj_ref = rs.GetObject(message="Bla", filter=8, preselect=False, subobjects=True)
if obj_ref:
return [obj_ref.Surface(),obj_ref.SelectionPoint()]
print "Surface:", obj_ref.Surface()
print "Selection Point:", obj_ref.SelectionPoint()
TestOffset()
Thank you Pascal.My goal is to create a offset curve and use it as a CNC path.
if you cousider the red curve as a surface i can obtain the green curve but not the light blue.
Do you have any idea how to fix it?
Other than that thanks for your help