Demonstrates creates a new document that is either a part, assembly, or hybrid intent.
Before running: Run from Scripts and Add-Ins. This sample may open dialogs or require interactive choices; keep Fusion in the foreground. No open document is required; the script creates a new design (or additional documents) as it runs.
import adsk.core, adsk.fusion
def run(context):
try:
app = adsk.core.Application.get()
# Specify if a hybrid, part, or assembly document should be created. If
# both are False, it defaults to creating a hybrid document.
createPart = False
createAssembly = False
# Create a new document. The Documents.add method always creates a hybrid document.
new_HybridDoc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
design: adsk.fusion.Design = new_HybridDoc.products.itemByProductType('DesignProductType')
# If a part or assembly document is wanted, modify the hybrid document to be the correct type.
if createPart:
# Sets the intent to be a part design.
design.designIntent = adsk.fusion.DesignIntentTypes.PartDesignIntentType
elif createAssembly:
# Sets the intent to be an assembly design.
design.designIntent = adsk.fusion.DesignIntentTypes.AssemblyDesignIntentType
except:
pass