Message 1 of 8
Issues replacing joint.geometryOrOriginOne
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all!
I want to replace the occurrence of a referenced component for another.
The already inserted component 'Insert1' is joined by a joint to 'Base' component, the joint.geometryOrOriginOne is a Joint origin defined in 'Insert1'.
When the component 'Insert2' is inserted to 'Base', I'd like to replace the joint.geometryOrOriginOne for a Joint Origin defined the same way inside 'Insert2', but I always get this error:
'RuntimeError: 5 : Provided input paths or alignments are not valid.'
This should be the final result, which can be easily replicated manually:
Here is the code and the designs which reproduce my issue:
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
rootComp = design.rootComponent
#Active project
project = app.activeDocument.dataFile.parentProject
#Design to insert
designsInProject = project.rootFolder.dataFiles
for designToInsert in designsInProject:
if designToInsert.name == 'Insert2':
break
#Get the joint in 'Base' design
joint = rootComp.joints.item(0)
#Rollback timeline
joint.timelineObject.rollTo(True)
#Insert design 'Insert2'
occInsert2 = rootComp.occurrences.addByInsert(designToInsert, adsk.core.Matrix3D.create(), True)
#Get the joint origin from design 'Insert2'
jointOriginInsert2 = occInsert2.component.jointOrigins.item(0)
#Replacement of joint origin in joint
joint.geometryOrOriginOne = jointOriginInsert2
#Move timeline to end
design.timeline.moveToEnd()
#Delete 'Insert1'
for occ in rootComp.allOccurrences:
if occ.component.name == 'Insert1':
occ.deleteMe()
break
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Any idea about this? Thanks in advance.