Community
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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cannot save project after running script

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Joshua.mursic
344 Views, 6 Replies

Cannot save project after running script

Hello,

 

I have a script that runs well and completes without issue. However, when I go to save the project I get the following error:

 

Error: The source asset Toolpath in document Untitled v1 has not referenced the target asset FusionAssetName in document Untitled v1!

Joshuamursic_0-1673993101863.png

 

I went through my script and commented out the sections until I found what is causing the issue, but I don't know how to change it to fix the save problem. 

 

I am using some tricks that I saw @kandennti  explaining in this thread:

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/create-new-cam-setups/m-p/10215806

as well as some others from other posts.

 

I think that the TextCommand UI.EnableCommandInput is causing issues.

# Select Z Axis for setup
zAxis = design.rootComponent.zConstructionAxis
app.executeTextCommand(u'UI.EnableCommandInput job_rotaryAxis')
sels.clear()
sels.add(zAxis)

 

 

 

Thanks in advance for any assistance,

 

Kind regards,

Josh

6 REPLIES 6
Message 2 of 7
kandennti
in reply to: Joshua.mursic

Hi @Joshua.mursic .

 

I was able to reproduce the phenomenon of not being able to save, but I don't know how to work around it.

Message 3 of 7
Joshua.mursic
in reply to: kandennti

Thank for taking the time to check this out.

A solution that you provided me to this question:
https://forums.autodesk.com/t5/fusion-360-api-and-scripts/activate-a-folder-in-the-cam-environment/t...
has given me another method to achieve what I am trying to do so I am not going to use this method. Thanks.

 

 

EDIT: My work around method is not working, very well. I would like to try and find a solution to this problem still.

Message 4 of 7
Joshua.mursic
in reply to: kandennti

I think that I found the issue,

 

zAxis = design.rootComponent.zConstructionAxis

 

This is referring to anitem in the design environment not the manufacturing environment. which I believe is causing the issue. 

 

I am using the methods you describe to select objects using ONK, however, I am having issues.

 

I am now trying to select this object in the browser tree using ONK.

Joshuamursic_0-1674083048022.png

 

This is the script that I am using to target it:

 

# Select Z Axis for setup
zAxisONK = u'ONK::CmpInst={}/Cmp={}/CmpInsts/CmpInst={}%3A1/Cmp={}/CmpInsts/CmpInst={}/Cmp={}/{}/{}/LeafType:16777216=0'.format(
    quote(app.activeDocument.name),
    quote(app.activeDocument.name),
    quote('CAM Component'),
    quote('CAM Component'),
    quote(cam.designRootOccurrence.name),
    quote(cam.designRootOccurrence.name),
    quote('OriginWorkGeometry'),
    quote('WorkAxis=Z'))
app.log(zAxisONK)
zAxisSelect = app.executeTextCommand(u'Commands.Select {}'.format(zAxisONK))
app.executeTextCommand(f'UI.EnableCommandInput job_rotaryAxis')
ui.activeSelections.add(zAxisSelect)

 

 

However I am getting this error:

 

RuntimeError: 3 : Invalid object path.

 

my script is returning this as the ONK:

 

ONK::CmpInst=TEST%20v0/Cmp=TEST%20v0/CmpInsts/CmpInst=CAM%20Component%3A1/Cmp=CAM%20Component/CmpInsts/CmpInst=TEST%20v0%3A1/Cmp=TEST%20v0%3A1/OriginWorkGeometry/WorkAxis%3DZ/LeafType:16777216=0

 

But when I use your Developers Small tool kit addon and get the ONK with this button

Joshuamursic_1-1674084498642.png

It get this ONK: 

 

ONK::CmpInst=TEST%20v0/Cmp=TEST%20v0/CmpInsts/CmpInst=CAM%20Component%3A1/Cmp=CAM%20Component/CmpInsts/CmpInst=TEST%20v2%3A1/Cmp=TEST%20v2/OriginWorkGeometry/WorkAxis=Z/LeafType:16777216=0

 

 

I think that the  'cam.designRootOccurrence.name' is getting the name before the document is fully saved, and is returning the wrong version number. But this is only a guess.

 

Is there a way to wait for the document to finish saving before continuing the code?

 

Message 5 of 7
kandennti
in reply to: Joshua.mursic

@Joshua.mursic .

 

Due to my busy schedule, I have not been able to confirm anything.

It is certainly likely that CAD elements are treated differently in design than in manufacture.

Message 6 of 7
kandennti
in reply to: Joshua.mursic

@Joshua.mursic .

 

Do not get "ONK" in the design state, but get "ONK" in the manufacture state.

It is faster to run a text command directly before running it in a script to check its operation.

Message 7 of 7

For people looking for answers to this bug, I think that I found the problem. If you target an individual mesh body to be used for machining, this error occurs, but if you instead put that mesh inside a new component and then target the entire component, this error does not seem to appear. 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report