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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sketch Offset Closed Loop Behavior after 1/23/16 update

Message 1 of 2
320 Views, 1 Reply

Sketch Offset Closed Loop Behavior after 1/23/16 update


After the recent update I found that the sketch.offset() method was not working for closed (connected) loops of sketchlines, below is some example code from the documentation, modified to form a closed loop with sketch lines. When run in its orginal state, it works as expected, but when modified to form a connected loop it produces an error (modified code marked below).


import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
        app = adsk.core.Application.get()
        ui  = app.userInterface
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        design = app.activeProduct
        # Get the root component of the active design.
        rootComp = design.rootComponent

        # Create a new sketch on the xy plane.
        sketches = rootComp.sketches
        xyPlane = rootComp.xYConstructionPlane
        sketch = sketches.add(xyPlane)

        # Draw two connected lines.
        lines = sketch.sketchCurves.sketchLines
        line1 = lines.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(3, 1, 0))
        line2 = lines.addByTwoPoints(line1.endSketchPoint, adsk.core.Point3D.create(1, 4, 0))
        # modified code --- 
        line3 = lines.addByTwoPoints(line1.startSketchPoint, line2.endSketchPoint)
        # Add a fillet.
        #arc = sketch.sketchCurves.sketchArcs.addFillet(line1, line1.endSketchPoint.geometry, line2, line2.startSketchPoint.geometry, 1)
        # Add the geometry to a collection. This uses a utility function that
        # automatically finds the connected curves and returns a collection.
        curves = sketch.findConnectedCurves(line1)
        # Create the offset.
        dirPoint = adsk.core.Point3D.create(0, .5, 0)
        offsetCurves = sketch.offset(curves, dirPoint, 1)
        if ui:



This is the error produced: and the sketch created:







 Please let me know if this is an issue or just my code, Thanks.




Message 2 of 2
in reply to: zarmsby

Change your code as below then it should work.

line3 = lines.addByTwoPoints(line2.endSketchPoint, line1.startSketchPoint)

There is validation on connected curves before executing offset. The validation requires the curves are end connected in order, which means the start point of one curve should be connected to the end point of the pervious curve. In your case above, the start point of line3 is connected to the start point of line1, they are not in order. Perhaps we need to enhance the validation to consider your case.

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