Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get points along a curve

1 REPLY 1
SOLVED
Reply
Message 1 of 2
jmperez6
1095 Views, 1 Reply

How to get points along a curve

Hello, is there a way to get points along a curve, like a sketch ellipse, fixed spline, or arc at 1 millimeter distance apart from each other? I know I can get the start point and the end point but is there a way to get points along the curve at every 1mm?

Thank you

1 REPLY 1
Message 2 of 2
kandennti
in reply to: jmperez6

Hi. jmperez6

 

1.png

 

 

Here is a sample to offset the sketch curve.
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-e20ca15a-fd06-11e4-aaf7-3417ebd3d5be

 

 

 

 

 

 

 

 

 

The following code creates a sketch point 1 mm from the start point.

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        #start
        app = adsk.core.Application.get()
        ui  = app.userInterface
        des = app.activeProduct
        
        #convert Unit:1mm to internalUnits
        unitsMgr = des.unitsManager
        mm = unitsMgr.convert(1.0, "mm", unitsMgr.internalUnits)
        
        #select
        selFilter = 'SketchCurves'
        msg = 'Select Sketch Curve'
        sel = ui.selectEntity(msg, selFilter)
        if sel is None:
            return
        
        #entity
        skt_crv = sel.entity
        
        #sketch
        skt = skt_crv.parentSketch        
        
        #WorldGeometry
        crv = skt_crv.worldGeometry
        
        #evaluator
        eva = crv.evaluator
        
        #startPoint&endPoint
        returnValue, startPoint, endPoint = eva.getEndPoints()
        if not returnValue :
            ui.messageBox('getEndPoints_NG')
            return
        
        #start parameter
        returnValue, start_prm = eva.getParameterAtPoint(startPoint)
        if not returnValue :
            ui.messageBox('getParameterAtPoint_NG')
            return
        
        #1mm Parameter
        returnValue, leng_1mm_prm = eva.getParameterAtLength(start_prm, mm)
        if not returnValue :
            ui.messageBox('getParameterAtLength_NG')
            return
        
        #1mm point
        returnValue, pnt3d = eva.getPointAtParameter(leng_1mm_prm)
        if not returnValue :
            ui.messageBox('getPointAtParameter_NG')
            return
        
        #to sketchPoints
        skt_point = skt.sketchPoints.add(pnt3d)
   
        #finish
        ui.messageBox('Done')
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report