Hi all
Is there Extend curve from both directions ?
any idea!
EX.3dm (2.8 MB)
Hi @PowerShape ,
You can do that with Grasshopper or with a small script.
I wrote a short script that you can use by calling EditPythonScript in the Command-box, copy paste the script into the editor and click on run. I added some comments explaining what the script does.
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
import Rhino.Geometry as rg
def Main():
curvesIds = rs.GetObjects("Select curves to extend")
if not curvesIds: return
extensionLength = rs.GetReal("Length", number=None, minimum=None, maximum=None)
if not extensionLength: return
rs.EnableRedraw(False)
curvesGeos = [sc.doc.Objects.Find(Id).Geometry for Id in curvesIds]
for i, curve in enumerate(curvesGeos):
rs.Prompt("Processing %s/%s"%(i+1, len(curvesGeos)))
"""Here you can choose what kind of extension type you want
-Rhino.Geometry.CurveExtensionStyle.Line --> Line
-Rhino.Geometry.CurveExtensionStyle.Arc --> Arc
-Rhino.Geometry.CurveExtensionStyle.Smooth --> Smooth
And for the curve side to extend:
None 0 Not the start nor the end.
Start 1 The frontal part of the curve.
End 2 The tail part of the curve.
Both 3 Both the start and the end of the curve. """
extendedCurve = curve.Extend(rg.CurveEnd(3), extensionLength, Rhino.Geometry.CurveExtensionStyle.Line) #Extends the curve
if extendedCurve is None:
print("ERROR: Could not extend curves")
return #Return if extension fails
sc.doc.Objects.AddCurve(extendedCurve) #Adds the objects to the model
rs.DeleteObjects(curvesIds) #Comment this out if you want to keep the original curves
rs.EnableRedraw(True)
if __name__ == "__main__":
Main()
Hope this helps!
Thank you for your help, it’s working fine. @pascal
I hope the developers will add this wish to Rhino