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: 

Where are Coincident Constraints saved?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
dellerXU4FF
362 Views, 3 Replies

Where are Coincident Constraints saved?

I created a rectangle using the 2-point-rectangle tool in a sketch.

Now I checked if i could find the object with the text command prompt.

In the geometricConstraint object, only the two horizontal and two vertical constraints are saved.

sketches.item(1).geometricConstraints.count 
4

Now I wonder where the four missing Coincident Constraints are stored that are visible when clicking at each point.

 

Any help is highly appreciated.

Thank you.

3 REPLIES 3
Message 2 of 4
kandennti
in reply to: dellerXU4FF

Hi dellerXU4FF.

 

I created the following script to check.
#Fusion360API Python script
#Author-kantoku
#Description-Coincident test

import adsk.core, adsk.fusion, traceback


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

        app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent

        # create sketch
        skts = root.sketches
        skt = skts.add(root.xYConstructionPlane)

        # create TwoPointRectangle
        pnt3d = adsk.core.Point3D
        pnt1 = pnt3d.create(1.0, 2.0, 0.0)
        pnt2 = pnt3d.create(3.0, 4.0, 0.0)

        lines = skt.sketchCurves.sketchLines
        lines.addTwoPointRectangle(pnt1, pnt2)

        # Assign a temporary ID as an attribute to the sketch point.
        # skt.sketchPoints.item(0) is the origin.
        for idx, sktPnt in enumerate(skt.sketchPoints):
            sktPnt.attributes.add(
                'test_ID',
                'ID',
                str(idx))
        
        # Get information in sketch
        info = []
        info.append('sketchCurves.count[{}]'.format(
            skt.sketchCurves.count)
        )
        info.append('sketchPoints.count[{}]'.format(
            skt.sketchPoints.count)
        )
        info.append('geometricConstraints.count[{}]'.format(
            skt.geometricConstraints.count)
        )
        info.append('--------------')

        for idx, line in enumerate(lines):
            sp = line.startSketchPoint
            ep = line.endSketchPoint
            info.append('lineIndex[{}] : startPointID[{}] : endPointID[{}]'.format(
                str(idx),
                sp.attributes.itemByName('test_ID', 'ID').value,
                ep.attributes.itemByName('test_ID', 'ID').value)
            )

        # show info
        ui.messageBox('\n'.join(info))
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
When executed, creates a TwoPointRectangle and displays a dialog at the end.
The dialog shows which sketch point the start and end points of each line are referring to by test ID.
1.png
 
I thought that the end points of each line refer to the same point, which meant coincidence constraint.
Message 3 of 4
dellerXU4FF
in reply to: kandennti

Thank you!

Message 4 of 4
BrianEkins
in reply to: dellerXU4FF

Here's a bit more info. Internally, there aren't coincident constraints to tie the end points of entities together. The UI makes it appear that way but it's a strictly for the UI. Actually the curves share the same sketch point and that's what ties them together. When you add a coincident constraint to connect two entities, Fusion is really adjusting the entities so the share a single point. If you delete the coincident constraint tying two entities together, Fusion is creating a new sketch point and changing one of the entities to use this new point so the are no longer associated. 

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

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report