Problem creating joint for imported component if referenced

Problem creating joint for imported component if referenced

r.michalczyk
Explorer Explorer
603 Views
2 Replies
Message 1 of 3

Problem creating joint for imported component if referenced

r.michalczyk
Explorer
Explorer

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) 
jointInput.setAsRigidJointMotion()
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.

0 Likes
Accepted solutions (1)
604 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

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
Website/Blog: https://EkinsSolutions.com
Message 3 of 3

r.michalczyk
Explorer
Explorer

Thank you so much @BrianEkins

0 Likes