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: 

Get a points x , y value in existing sketch

Message 1 of 11
2228 Views, 10 Replies

Get a points x , y value in existing sketch



I have an existing sketch, it is just a plain sketch, no features, extrudes etc.  As driven dimensions cannot be referenced as parameters YET I thought a hacky solution would be to get the x and y co-ords of the point I am interested in and then do a bit of geometry in python to get the dimension I need.


However, I haven't had any luck in getting API access to find the point.


I have included the screen shot, the yellow point in the middle is the one I'm interested in and the red dimension is the one I need to access.  It is all relative to the origin.


Unfortunately adding the dimension as a parameter is not possible because it must remain driven.


Thanks in advance,



Message 2 of 11
in reply to: drawing-admin



I am not sure if I get your point or not. Please refer to the following sample how to find non-driven dimension and associated points.


BTW: the codes are assuming there is a sketch in current design and there are two points and one non-driven dimension in the sketch.





import adsk.core, adsk.fusion, traceback
import os

def run(context):
    ui = None
        app = adsk.core.Application.get()
        ui = app.userInterface
        design = adsk.fusion.Design.cast(app.activeProduct)
        root = design.rootComponent
        sketch = root.sketches.item(0)
        dimension = adsk.fusion.SketchLinearDimension.cast(sketch.sketchDimensions.item(0))
        p1 = dimension.entityOne
        p2 = dimension.entityTwo
        ui.messageBox('Driven Dimension: {}, entity one: {}, entity two: {}'.format(dimension.isDriving, p1.objectType, p2.objectType))

        if ui:

Non-driven dimension.png

Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 3 of 11
in reply to: marshaltu

Hi Marshal,


Firstly, thank you for putting that code up - very useful. 


However my problem remains how do I retrieve the dimension value (47.196 mm in your example) as the SketchDimension Object does not have a value or expression parameter that can be returned.  I know it has a parameter, but as this dimension must be driven I cannot associate a parameter with the dimension.


I don't need to know if it is driven or not I need the Value please.


Thanks again





SketchDimension Object help found here:




Message 4 of 11
in reply to: drawing-admin

The code below show part of what you need.  It asks for a point selection and then reports it's location. Coordinates for sketch geometry will be returned with respect to the sketch coordinate system.  If you want to find it's location in the model you can use the worldGeometry property instead of geometry.  The hardest part of your request is finding that particular point. There will be a lot of sketch points in that sketch and you'll need to find something unique about that specific point.  Possibly the type of constraints used to position it or maybe it's position relative to the other points. It would also be possible to add an attribute to the point, effectively naming it, so that you can find it again later. Without knowing your complete workflow it's difficult tp be very specific about a solution.


import adsk.core, adsk.fusion, traceback

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

        pntSel = ui.selectEntity('Select a sketch point', 'SketchPoints') 
        if pntSel:
            pnt = adsk.fusion.SketchPoint.cast(pntSel.entity)
            ui.messageBox('Point: ' + str(str(pnt.geometry.asArray())))
        if ui:

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 5 of 11
in reply to: drawing-admin

If this is a ParametricDesignType, driven sketch dimensions will still have a parameter that will hold the value.  In this case you could obtain the value with:



But if the design is a DirectDesignType (non parametric), then the dimension will not have a parameter value.  In this case, we do not have a convenience method to get the parameter value (normally it is obtained from the parameter).  We should add a convenience method to get the dimension value and text directly from the dimension object (instead of going through the parameter).  I will file an issue for this.  But in the meantime, as you mentioned you can calculate it from the entities of the linear dimension.  I believe they will always be sketch points, and in your case they definitely should be, so you could use code like the following to get the linear dimension's distance value.


dim = SketchLinearDimension.cast(ui.activeSelections.item(0).entity)
pt1 = SketchPoint.cast(dim.entityOne).geometry
pt2 = SketchPoint.cast(dim.entityTwo).geometry
dist = {
    DimensionOrientations.AlignedDimensionOrientation: lambda: pt1.distanceTo(pt2),
    DimensionOrientations.HorizontalDimensionOrientation: lambda: abs(pt1.x - pt2.x),
    DimensionOrientations.VerticalDimensionOrientation: lambda: abs(pt1.y - pt2.y)


Kris Kaplan
Message 6 of 11
in reply to: KrisKaplan

Hi Kris,


Thank you, I've been trying down this route, code below, but it only returns the named parameters.


def writeTheParameters():
    app = adsk.core.Application.get()
    design = app.activeProduct
    result = ""
    for _param in design.allParameters:
            paramUnit = _param.unit
            paramUnit = ""
        result = result + "\"" + +  "\",\"" + paramUnit +  "\",\"" + _param.expression + "\",\"" + _param.comment + "\"\n"    
    print (result) 

Return Value


>>> d1","mm","35.00 mm",""
"d2","mm","75.00 mm",""
"d4","mm","50 mm",""
"d6","mm","20 mm","


My example sketch and parameters:




So I don't follow why the yellow highlighted driven dimensions are not printed?


Clearly they must be somewhere, probably d3 and d5 which appear to be skipped in the Model Parameter list.  But how to access?



Message 7 of 11
in reply to: drawing-admin

it looks like it has been a while and still no solution.

Trying to bump the post up for fresh ideas.

Obviously I am in the same boat trying to get driven dimention into API.


Thanks as Always

Message 8 of 11
in reply to: EGonchar

Hi Mr. Gonchar,


A driven dimension is driven by something. It is a dependent variable. If you want to change it or include dynamics of it into your script consider replicate formulas driving it into your script. Any change to driving variables influenced by you or external factor (possibly in a user parameters disguise ) will be replicated in your script.  It would be like creating a patch of the private parallel universe and you would be the creator ... but please do not extend the patch to much.





Message 9 of 11
in reply to: MichaelT_123

I understand this approach, but seeking the functionality (like Inventor offers) where you come up with a parametric problem and driven parameter reports back to you how did the point of interest changed after you changed your parameters.


At this point in the UI of Fusion, it looks like you can measure the point of interest but as other users have reported it does not show up in the parameters list.


Message 10 of 11

@KrisKaplan , @ekinsb is there any update to this? It would be great to be able to grab the information from a driven dimension in the API. 

Message 11 of 11

@therealsamchaney .


In the GUI, the feature has been added in the Ver2.0.12157 update, so I tried it out in the API. 


I have prepared a sketch like this.



Then, I created the script.

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui = adsk.core.UserInterface.cast(None)
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        skt: adsk.fusion.Sketch = root.sketches[0]
        dims = skt.sketchDimensions
        dims[1].parameter.expression = 'd1'

        if ui:


When I ran the script while I was in the sketching process, it worked fine, but when I ran it while I was out of the sketching process, I got an error.


It seems like a bug, but I couldn't quite figure out why.

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