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: 

API won't delete sketchText

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
erik
384 Views, 4 Replies

API won't delete sketchText

I have an issue regarding the deleting of sketchText.

Maybe I made a mistake in my code or misunderstood the API.

 

I am currently trying to delete all sketchText in a sketch, but the API throw an exception when trying to run a deleteMe method.

To test it I am currently just trying to delete the first sketchText in the sketch.

 

This is my code:

 

sketchText = adsk.fusion.SketchText.cast(_destinationSketch.sketchTexts.item(0))
_ui.messageBox(str(sketchText.height) + '\n' + sketchText.text + '\n' + str(sketchText.deleteMe))
sketchText.deleteMe()

  

This is my messageBox:

 

MessageBox.PNG

 

And this is my error:

 

Error.PNG

 

If anyone has a solution or advice it would be appreciated! 🙂

 

- Erik

4 REPLIES 4
Message 2 of 5
marshaltu
in reply to: erik

Hello,

 

Thank you for reporting the issue to us. It was an API bug and has been logged as UP-36835 in our internal system.

 

There is a workaround for you right away. You can delete a sketch by deleting one of its boundary lines. Please refer to the following codes.

 

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

def run(context):
    
    ui = None
    
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface

        design = adsk.fusion.Design.cast(app.activeProduct)
        rootComp = design.rootComponent;
        
        sketch = rootComp.sketches.item(0)
        for text in sketch.sketchTexts:
            lines = text.boundaryLines
            lines.item(0).deleteMe()
        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

Thanks,

Marshal



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 3 of 5
erik
in reply to: marshaltu

Oh, thats why.

 

Thank you for providing the workaround.

Is this a permanent workaroung and will there be sent a notification when the fix is implementet?

 

- Erik

Message 4 of 5
marshaltu
in reply to: erik

Hello,

 

We will update the thread once the issue gets fixed. Ideally the workaround should keep valid.

 

Thanks,

Marshal 



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 5 of 5
erik
in reply to: marshaltu

Thank you!

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