Hello,
I'm trying to update a drawing using the updateAllReferences method as follows:
app = adsk.core.Application.get()
drawing = adsk.drawing.Drawing.cast(app.activeProduct)
drawing.updateAllReferences()
AttributeError: 'Drawing' object has no attribute 'updateAllReferences'
Does anyone know if I'm missing something in the code?
Have also tried:
app = adsk.core.Application.get()
active = app.activeDocument
active.updateAllReferences()
Thank you
Solved! Go to Solution.
Solved by kandennti. Go to Solution.
Solved by kandennti. Go to Solution.
This is something the team has worked on and will be supported in one of the upcoming Major releases.
Below code will work in that release.
app = adsk.core.Application.get()
active = app.activeDocument
active.updateAllReferences()
Regards,
Hi @ianjwellings .
Try this.
# Fusion360API Python script
import traceback
import adsk.core
import adsk.drawing
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
cmdDef: adsk.core.CommandDefinition = ui.commandDefinitions.itemById(
'FusionDocUpdateCommand'
)
cmdDef.execute()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Will they enhance Draw next to enhance CAM?
That is something to look forward to.
Thank you for this - it worked great. Do you know if there is also a command to export the drawing as a dxf file?
Unfortunately, the API does not provide much functionality for Drawing, so the only thing that can be exported is PDF.
This command works perfectly for updating the drawing. I would like to run another function after this command is executed however the function runs before this command has finished. Is it possible to wait until the drawing update command is finished and then call an export_drawing() function?
def update_drawing():
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
cmdDef: adsk.core.CommandDefinition = ui.commandDefinitions.itemById('FusionDocUpdateCommand')
cmdDef.execute()
####WAIT FOR COMMAND TO FINISH###
export_drawing()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
If you want to perform an update in the middle of a process, you can do so by doing the following.
def update_drawing():
ui = None
try:
app = adsk.core.Application.get()
# ui = app.userInterface
# cmdDef: adsk.core.CommandDefinition = ui.commandDefinitions.itemById('FusionDocUpdateCommand')
# cmdDef.execute()
app.executeTextCommand(u'Commands.Start FusionDocUpdateCommand')
####WAIT FOR COMMAND TO FINISH###
# export_drawing()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Can't find what you're looking for? Ask the community or share your knowledge.