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: 

Problem creating joint for imported component if referenced

Message 1 of 3
258 Views, 2 Replies

Problem creating joint for imported component if referenced

I try to import component to existing geometry and then position it by creating joint. Here is the code:


newOccurence = rootComp.occurrences.addByInsert(myComponent, adsk.core.Matrix3D.create(), True)
# if "isReferencedComponent=False" then joint-problem resolved!
# geometry that is already existing = existingCircle
# geometry for imported component
helpSketch = newOccurence.component.sketches.itemByName("JointPositioning")
curve = helpSketch.sketchCurves.item(0)

# Create the first joint geometry - taken sketch in referenced component
geometryOrOriginOne = adsk.fusion.JointGeometry.createByCurve(curve, adsk.fusion.JointKeyPointTypes.CenterKeyPoint)
# Create the second joint geometry with the existingCircle
geometryOrOriginTwo = adsk.fusion.JointGeometry.createByCurve(existingCircle, adsk.fusion.JointKeyPointTypes.CenterKeyPoint)

joints = rootComp.joints
jointInput = joints.createInput(geometryOrOriginOne , ggeometryOrOriginTwoeo2) 
joint = joints.add(jointInput)     # Create the joint


API joint problem.jpg

I have to use "isReferencedComponent=True" option but then it gives me the error (above).

If I use "isReferencedComponent=False" the problem is gone. I guess the problem comes from "geometryOrOriginOne" being a sketch in referenced component, but how to overcome that? Please give me a hint.

Labels (1)
Message 2 of 3
in reply to: r.michalczyk

The problem is the context of the geometry you're using to create the joint. You're getting the geometry directly from the sketch, which is owned by the referenced component.  If you have two occurrences of this part in the assembly, you effectively have two of the sketch curves; one for each occurrence.  Because of this Fusion needs more information to be able to know which sketch curve you want.  To do this it also needs to know which occurrence the desired sketch curve is in.  You do this by calling the createForAssemblyContext method on the sketch entity and pass in the occurrence.  This will return a "proxy" for the sketch entity that is in the context of the assembly and can be used as input to create the constraint.


For more information about proxies, you can read this topic in the online help.

Brian Ekins
Inventor and Fusion 360 API Expert
Message 3 of 3
in reply to: r.michalczyk

Thank you so much @BrianEkins

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

Post to forums  

Technology Administrators

Autodesk Design & Make Report