Hello,
this is a sample script that prompts the user for a file name and then copies the design from that file to the active document. You only need to have the file that is to receive the design data opened.
You could further adjust the script to copy only selected components from the parent design or place them in a specific spot. Now, by default, the script uses origin for placement.
Hope this helps
import adsk.core, adsk.fusion, traceback
def run(context):
try:
_app = adsk.core.Application.get()
_ui = _app.userInterface
project = _app.data.activeProject
fileToInsert = None
fileNameToLookFor = None
# get input from the user
isValid = False
input = '' # placeholder
while not isValid:
(fileNameToLookFor, isCancelled) = _ui.inputBox('Enter a file name to look for:', 'File Name', input)
if isCancelled:
return
for file in project.rootFolder.dataFiles:
if file.name == fileNameToLookFor:
fileToInsert = file
isValid = True
break
# check if desired file was found
if fileToInsert == None:
_ui.messageBox(f"File with name {fileNameToLookFor} was not found. Try again.")
des = adsk.fusion.Design.cast(_app.activeProduct)
root = des.rootComponent
occ = root.occurrences.addByInsert(fileToInsert, adsk.core.Matrix3D.create(), True)
except:
if _ui:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))