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
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.