Constrain a line to a circle

Constrain a line to a circle

billbedford
Advocate Advocate
487 Views
1 Reply
Message 1 of 2

Constrain a line to a circle

billbedford
Advocate
Advocate

I'm looking for the form of an entity that can be used to give a coincident constraint between a line end-point and a circle. 

 

Thanks in advance

0 Likes
Accepted solutions (1)
488 Views
1 Reply
Reply (1)
Message 2 of 2

BrianEkins
Mentor
Mentor
Accepted solution

The code below creates a circle, a line, and a coincident constraint between them.

import adsk.core, adsk.fusion, traceback

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

        sk = root.sketches.add(root.xYConstructionPlane)
        circle = sk.sketchCurves.sketchCircles.addByCenterRadius(
                                adsk.core.Point3D.create(0,0,0), 5)
        line = sk.sketchCurves.sketchLines.addByTwoPoints(
                                adsk.core.Point3D.create(5,0,0),
                                adsk.core.Point3D.create(8,3,0))
        
        sk.geometricConstraints.addCoincident(line.startSketchPoint, circle)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))  
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com