- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm pretty new to the Fusion 360 API and python. I've been trying to manipulate various joints in a very complex model. In order to do that, I have to find the joints (regular and As-Built). I've been struggling. To simplify the analysis of my problems, I've created a simple script to just find all the As-Built joints. It fails.
I've read everything I can from the forum and haven't been able to solve this issue. This is the code:
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
rootComp = design.rootComponent
aj = rootComp.allAsBuiltJoints
ui.messageBox('Number of Joints: ' + str(aj.count))
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
This is the error message:
Failed:
Traceback (most recent call last):
File "C:/Users/DWR/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/FindJoint2/FindJoint2.py", line 14, in run
aj = rootComp.allAsBuiltJoints
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users/DWR/AppData/Local/Autodesk/webdeploy/production/3167d85f5fd4280287d8295f20592fa13b977617/Api/Python/packages\adsk\fusion.py", line 55135, in _get_allAsBuiltJoints
return _fusion.Component__get_allAsBuiltJoints(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 3 : object does not belong to the occurrence's component
I also can't figure out how to count the number of items in the returned list, but that is another problem.
Thanks, in advance for any help you can provide.
Solved! Go to Solution.