Create circle using 3 points via script

Create circle using 3 points via script

fredrikcarlssonnlm
Explorer Explorer
816 Views
8 Replies
Message 1 of 9

Create circle using 3 points via script

fredrikcarlssonnlm
Explorer
Explorer

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

0 Likes
817 Views
8 Replies
Replies (8)
Message 2 of 9

kandennti
Mentor
Mentor

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

fredrikcarlssonnlm
Explorer
Explorer

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.

0 Likes
Message 4 of 9

kandennti
Mentor
Mentor

@fredrikcarlssonnlm -San.

 

It is running fine in my environment.

1.png

Fusion360 Ver2.0.18719

ms_python v2023.20.0

0 Likes
Message 5 of 9

BrianEkins
Mentor
Mentor

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

fredrikcarlssonnlm
Explorer
Explorer

Thanks!

I will try this directly!

0 Likes
Message 7 of 9

fredrikcarlssonnlm
Explorer
Explorer

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.

0 Likes
Message 8 of 9

kandennti
Mentor
Mentor

@fredrikcarlssonnlm -San.

 

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

1.png

0 Likes
Message 9 of 9

BrianEkins
Mentor
Mentor

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
0 Likes