Adding ends to both side offset in Rhino Python

Hi !
I wanted to use both side offset in rhino python coding . I have added 2 offsets as of now,one with positive distance and another with a negative distance .I have also added the corner style,but unable to add the end type (Straight) to the 2 offsets so as to join them.Would be great you could please help me with this.

Below is the code
def OffsetCurve2SidesSample():
crvID=rs.GetObject(“Select curve to offset 2 sides”,4,preselect=True)
if not crvID: return
dist=rs.GetReal(“Offset distance”,minimum=tol)
if dist == None: return

plane = rs.CurvePlane(crvID)
if not plane: plane = rs.ViewCPlane()

msg="Offset 2 sides failed!"
do first offset positive distance
if offset1:
#do second offset negative distance
if offset2:
if len(offset1)== 1 and len(offset2)==1:
msg="Successfully offset one curve both sides"
print msg


It’s unnecessary to start a new topic with the same question you have already asked in another topic…

To answer your question, have a look at the full script I posted in the other thread, that one attempts to add different kind of ends to the offsets. In that case you need to make sure that the offset results will actually work to do this.

If you are just going to connect the ends with straight lines, you can use RhinoCommon curve.PointAtStart and curve.PointAtEnd to get the start and end points of the offsets. If you want to work with curves that have already been added to the document, that would be pt=rs.CurveStartPoint(crv_ID) or rs.CurveEndPoint(crv_ID). In principle all you need to do after that is add a line between the two start points and another between the two end points (assuming the offset is successful and yields only 2 open curves).

You can either add the lines directly to the document with lineID=rs.AddLine(ptA,ptB) or virtually with line=Rhino.Geometry.Line(ptA,ptB). I’ll let you look into how to join the various elements if you want a closed curve.


Sorry for posting it at two different places.I did it so that when in future someone is searching this very topic in the forum ,as I did before posting,so he/she will get it directly ,without having to repost the query separately.Thanks for the reply.It was really helpful for my project :smile: