Rigid joint between an external inserted component and a sketch point fails

Rigid joint between an external inserted component and a sketch point fails

Hyger
Explorer Explorer
537 Views
3 Replies
Message 1 of 4

Rigid joint between an external inserted component and a sketch point fails

Hyger
Explorer
Explorer

I'm trying to insert an external component and rigid join it to sketch point, but i'm getting this error

return _fusion.Joints_add(self, input)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 3 : Provided input paths for joint are not valid.

 

this is my code.

app = adsk.core.Application.get()
ui  = app.userInterface
des = adsk.fusion.Design.cast(app.activeProduct)
root = adsk.fusion.Component.cast(des.rootComponent)

#Select a face to make sketch on
face = ui.selectEntity("Select a Planar Face", "PlanarFaces").entity

#Make sketch on selected face
sketch = root.sketches.add(face)

#Add a sketch point
points = sketch.sketchPoints
sketchPoint = points.add(adsk.core.Point3D.create(0, 10, 0))

#Find component
exampleComponent = app.data.activeHub.dataProjects.item(0).rootFolder.dataFolders.itemByName("Autodesk Example").dataFiles.item(0)

#Insert Component
instantiate = root.occurrences
instantiateComponent = instantiate.addByInsert(exampleComponent, adsk.core.Matrix3D.create(), True)

#Get origin point
originComponent = instantiateComponent.component.originConstructionPoint

#Create joint geometry
jointPointComponent = adsk.fusion.JointGeometry.createByPoint(originComponent)
jointPointSketch = adsk.fusion.JointGeometry.createByPoint(sketchPoint)

#Joint settings
joints = root.joints

joint = joints.createInput(jointPointComponent, jointPointSketch)

#joint.angle = adsk.core.ValueInput.createByString('0 deg')
#joint.offset = adsk.core.ValueInput.createByString('0 mm')
joint.isFlipped = False
joint.setAsRigidJointMotion()

#Create joint
joints.add(joint)

when i do the same manually it's no problem.

hope someone can help me

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

Jorge_Jaramillo
Collaborator
Collaborator
Accepted solution

Hi,

 

I couldn't make it work as you have it, since I got the same error message everytime a point from the imported component is used to make the joint.

A workaround that worked for me was to import the component as a child of another component, which was created locally.

So the hierarchy looks like the following:

root

sketch (with point1)

component1

importedComponent

Make component1 not grounded to parent (to let it move) and make importedComponent grounded to parent (will move with its parent).

Then make the joint between point1 and component1's originConstructionPoint.

 

I hope this can help as a workaround for you, while Fusion Team could investigate a possible bug whit this method.

 

Regards,

Jorge Jaramillo

 

0 Likes
Message 3 of 4

Hyger
Explorer
Explorer

Thank you! that worked

 

Although it's kind of a hack, but i'm going to use it until it gets fixed

 

Thank you again!

Message 4 of 4

BrianEkins
Mentor
Mentor

I don't believe there is a problem with the API here. Here's a slightly modified version of the original program that works. The difference is that I added line 25 so that the point used later is a proxy of the origin point in the other component. This idea of "proxies" is discussed in the user manual

app = adsk.core.Application.get()
ui  = app.userInterface
des = adsk.fusion.Design.cast(app.activeProduct)
root = adsk.fusion.Component.cast(des.rootComponent)

#Select a face to make sketch on
face = ui.selectEntity("Select a Planar Face", "PlanarFaces").entity

#Make sketch on selected face
sketch = root.sketches.add(face)

#Add a sketch point
points = sketch.sketchPoints
sketchPoint = points.add(adsk.core.Point3D.create(0, 10, 0))

#Find component
exampleComponent = app.data.activeHub.dataProjects.item(0).rootFolder.dataFolders.itemByName("Autodesk Example").dataFiles.item(0)

#Insert Component
instantiate = root.occurrences
instantiateComponent = instantiate.addByInsert(exampleComponent, adsk.core.Matrix3D.create(), True)

#Get origin point
originPoint = instantiateComponent.component.originConstructionPoint
originPoint = originPoint.createForAssemblyContext(instantiateComponent)

#Create joint geometry
jointPointComponent = adsk.fusion.JointGeometry.createByPoint(originPoint)
jointPointSketch = adsk.fusion.JointGeometry.createByPoint(sketchPoint)

#Joint settings
joints = root.joints

joint = joints.createInput(jointPointComponent, jointPointSketch)

#joint.angle = adsk.core.ValueInput.createByString('0 deg')
#joint.offset = adsk.core.ValueInput.createByString('0 mm')
joint.isFlipped = False
joint.setAsRigidJointMotion()

#Create joint
joints.add(joint)

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes