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: 

How to open a module inside another module?

1 REPLY 1
Reply
Message 1 of 2
jmperez6
175 Views, 1 Reply

How to open a module inside another module?

Hello, I have a question. How do you run a module/script inside another module/script?
To clarify, I have created a small GUI that runs on Fusion 360 (a python script) and I want to call another script that creates a small reference model on the CURRENT window/tab of Fusion 360 (in other words, the same window where the GUI is at). The reference is created when I click one of the buttons on the GUI. However, when I click said button, it creates the reference but on a new tab/file instead of the one with the GUI. So how am I able to make sure the reference is created in the same window/tab as the GUI?

 

Here is a code snippet of the buttons on the GUI:

 

if cmdInput.id == '_place':

addRow(tableInput)

if cmdInput.id == '_load':

addRow(tableInput)

if cmdInput.id == '_browse':

browse()

if cmdInput.id == '_reference':

referrence()

 

 

and here is the referrence() method that calls the script that creates the reference model.

 

def referrence():

test3.run(contextt)

ctypes.windll.user32.MessageBoxW(0, "REFERRENCE COMPLETED!!!!!!!!!!", "Referrence", 1)

 

 

 

and here is a snippet of the python script test3 that creates a reference model in a new window/file.

 

import adsk.core, adsk.fusion, adsk.cam, traceback

 

def run(context):

ui = None

try:

app = adsk.core.Application.get()

ui = app.userInterface

 

#crreate a document

doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)

 

product = app.activeProduct

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

 

#get the root component of the active design

rootComp = design.rootComponent

 

 

 

1 REPLY 1
Message 2 of 2
ekinsb
in reply to: jmperez6

Fusion doesn't currently support the execution of one script from another.  This would be a good feature to support in the future but it's not in our current backlog.  A workaround is instead of using simple scripts you can define commands for your functionality.  A script can find and execute any existing command.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog

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