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: 

Which direction is positive z in the API?

Message 1 of 2
189 Views, 1 Reply

Which direction is positive z in the API?

I have the following script which creates, a circular sketch, 2 sketch points and 2 sketch lines (as below).




The code for this is shown below (based on the Construction Plane API sample)



import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
        app = adsk.core.Application.get()
        ui = app.userInterface

        # Create a document.
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)

        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)

        # Get the root component of the active design
        rootComp = design.rootComponent

        # Create sketch
        sketches = rootComp.sketches
        sketch = sketches.add(rootComp.xZConstructionPlane)

        # Create sketch circle
        sketchCircles = sketch.sketchCurves.sketchCircles
        centerPoint = adsk.core.Point3D.create(0, 0, 0)
        sketchCircles.addByCenterRadius(centerPoint, 5.0)

        # Create sketch line
        sketchLines = sketch.sketchCurves.sketchLines
        startPoint = adsk.core.Point3D.create(5, 5, 0)
        endPoint = adsk.core.Point3D.create(5, 10, 0)
        sketchLineOne = sketchLines.addByTwoPoints(startPoint, endPoint)
        endPointTwo = adsk.core.Point3D.create(10, 5, 0)
        sketchLineTwo = sketchLines.addByTwoPoints(startPoint, endPointTwo)

        # Create two sketch points
        sketchPoints = sketch.sketchPoints
        positionOne = adsk.core.Point3D.create(0, 5.0, 0)
        sketchPointOne = sketchPoints.add(positionOne)
        positionTwo = adsk.core.Point3D.create(5.0, 0, 0)
        sketchPointTwo = sketchPoints.add(positionTwo)

        if ui:



`startPoint` which is created with coordinates (5, 5, 0) is placed in position (5, 0, -5) according to my axis in the top right corner. Given that the sketch is on the xZConstructionPlane I would be able to understand how specifying (5, 5, 0) ends up as (5, 0, 5), but I cannot understand how (5, 5, 0) maps to (5, 0, -5)??

Labels (1)
Message 2 of 2
in reply to: siliconlad

You can get information about the orientation of sketches in the API a few different ways. For example you can get the xDirection and yDirection from the sketch object. Here's a sketch created on the xZConstructionPlane



sketch.xDirection #(1.0, 0.0, 0.0)
sketch.yDirection #(0.0, 0.0, -1.0)



I've added the asArray() output next to each line. So the sketch positive X aligns to world/design positive X, sketch positive Y aligns to world/design negative Z.

This aligns with what is seen in the UI as well if you open up the sketch and look at the labelled axis



One last thing to note is that Fusion uses right handed coordinate systems.

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