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: 

Create circle using 3 points via script

8 REPLIES 8
Reply
Message 1 of 9
fredrikcarlssonnlm
392 Views, 8 Replies

Create circle using 3 points via script

Hey

We want to create a circle using 3 points in a 3 dimensional space using scrips in Fusion360.

I dont find any fucntion for this.

 

There is alot of functions to create circles but not to create a circle from 3 points.

 

Br

Fredrik

8 REPLIES 8
Message 2 of 9

Hi @fredrikcarlssonnlm -San.

 

Try using the addByThreePoints method.

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion

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

        skt: fusion.Sketch = root.sketches.add(
            root.xYConstructionPlane
        )
        skt.sketchCurves.sketchCircles.addByThreePoints(
            core.Point3D.create(1,0,0),
            core.Point3D.create(2,1,2),
            core.Point3D.create(0,1,-1),
        )

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Message 3 of 9

Have you tried this function?

Seems to be coming directly from ChatGPT?

 

We do not get this to work currently and have already tries this sadly.

Message 4 of 9

@fredrikcarlssonnlm -San.

 

It is running fine in my environment.

1.png

Fusion360 Ver2.0.18719

ms_python v2023.20.0

Message 5 of 9
BrianEkins
in reply to: kandennti

addByThreePoints is not a method imagined by ChatGPT. Here's the official Fusion documentation for it.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-bb94f635-2b1f-4ee2-ad64-dc2418a8584a

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 6 of 9

Thanks!

I will try this directly!

Message 7 of 9

Does this work with 3 dimensional points?

All the points are on the same construction plane but they dont have the same x,y or z cordinate.

Message 8 of 9

@fredrikcarlssonnlm -San.

 

If there are three points in a straight line, you will probably get an error, but otherwise it is fine.

1.png

Message 9 of 9
BrianEkins
in reply to: kandennti

It does work in 3D space. It uses the coordinate system of the sketch. All sketches are 3D; it's just that we usually only draw on their X-Y plane, but they support geometry that exists outside that plane. 

 

If your coordinates are with respect to model space, you can use the Sketch.modelToSketchSpace method to convert the model space coordinates into sketch space coordinates and then use themto create your circle.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

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

Post to forums