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: 

Script Error: Script File does not Exist

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
1016 Views, 4 Replies

Script Error: Script File does not Exist

I am trying to run a script that I have found on the forums here (https://forums.autodesk.com/t5/fusion-360-design-validate/parts-list-with-dimensions/td-p/6989386) The post shows that the Add-in is no longer valid or has been removed. Later down the list, there's a hand written script that someone posted to print dimensions to console. 

 

I copied that code, the launch coding to run the script, created a new script, and then saved the coding. 

After some debugging and google searches, I'm at a spot where I need some advice and guidance. 

 

Below is the coding:

 

 

import adsk.core, adsk.fusion

def run(context):
    app = adsk.core.Application.get()

    product = app.activeProduct
    design = adsk.fusion.Design.cast(product)

    # Get the root component of the active design.
    rootComp = design.rootComponent

    # Get occurences from root
    occurrences = rootComp.occurrences

    for idx in range(0, occurrences.count):
        occ = occurrences.item(idx)
        subcomp = occ.component
        for bidx in range(0, subcomp.bRepBodies.count):
            body = subcomp.bRepBodies.item(bidx)

            dimvector = body.boundingBox.minPoint.vectorTo(body.boundingBox.maxPoint).asPoint()
            dims=sorted(dimvector.asArray())

            formx = product.unitsManager.formatInternalValue(dims[0])
            formy = product.unitsManager.formatInternalValue(dims[1])
            formz = product.unitsManager.formatInternalValue(dims[2])
            print (f'{idx},{body.name}, {formx}, {formy}, {formz}\r')
            subcomp.description=f'{formx} x {formy} x {formz}'

 

 

 Below is the Run command

 

 

import neu_dev; neu_dev.run_script(r"C:\Users\jon\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\Scripts\partsizes.py")

 

 

when I paste this into the Console and hit enter it reads out:

 

Traceback (most recent call last):

File "<string>", line 1, in <module>

NeutronPythonException.TextCmdException: script file does not exist!

 

I can physically see the .py file at the location, yet Fusion says that the script does not exist.

 

Any help in making this work or pointing me in the direction of something similar to this would be greatly appreciated.

Thank you!

 

Labels (1)
4 REPLIES 4
Message 2 of 5
JeromeBriot
in reply to: Anonymous

Hello,

 

To run a script, go to the TOOLS panel, then select "Scripts and Add-Ins" in the ADD-INS menu.

 

Select the script you want to run in the list and click on Run at the bottom of the dialog. If the script is not listed, click on the small green "+" button next to "My scripts" at the top of the dialog and select its folder location.

 

Tags (3)
Message 3 of 5
Anonymous
in reply to: JeromeBriot

I've been trying that, but I keep getting a script not found message.

 

I clicked the green "+" sign and created a new script, pasted the script into visual studio then saved it as a .py

I can click "Run" from that interface, but nothing happens. When I go to copy / paste the Run command into the console, it pushes an error that says script is not found. I am lost on what to expect when I click run on the script interface. It does not prompt that error, but i don't see any feedback or created text with the information. 

 

Is there an add-in that would print out the bodies ( length of x , y , z ) into a text or viewable area that i would be able to see?

 

Im fairly new to coding and am stuck trying to figure out how to create a list of dimensioned bodies. 

Message 4 of 5
JeromeBriot
in reply to: Anonymous

Don't use the run button in Visual Studio Code. Use the one at the bottom of the dialog in Fusion 360:

 

run-debug.PNG


@Anonymous wrote:

i don't see any feedback or created text with the information. 

Replace the line:

print (f'{idx},{body.name}, {formx}, {formy}, {formz}\r')

By:

ui.messageBox(f'{idx},{body.name}, {formx}, {formy}, {formz}\r')

 

You can also use the Debug button (see image above) with the print statement. You need to open the OUTPUT window in VS Code.

 

Message 5 of 5
Anonymous
in reply to: JeromeBriot

thank you so much for the reply. 

 

I'll get that line changed out and try the debug!

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report