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: 

Delete previously created construction planes when running script

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
peter.pant
126 Views, 3 Replies

Delete previously created construction planes when running script

Hello all,

I've developed a script for creating a specific geometry. When adjusting my script, I run it again, and for this purpose I have created a simple function to delete all construction planes that were created in a previous run, ,and it is called at the beginning of the run-section. However, this is not successful, since there are always some of them remaining even if the new geometry and its construction planes were created. Do you have any idea why this happens? Here is my function:

 

def plane_Delete():
    app=adsk.core.Application.get()
    design=adsk.fusion.Design.cast(app.activeProduct)
    rootComp=design.rootComponent

    for plane in rootComp.constructionPlanes:
        plane.deleteMe()
 
Thank you in advance!
3 REPLIES 3
Message 2 of 4
kandennti
in reply to: peter.pant

Hi @peter.pant .

 

I'm not sure, because I don't have much information, but you could try changing the order in which they are deleted.

def plane_Delete():
    app=adsk.core.Application.get()
    design=adsk.fusion.Design.cast(app.activeProduct)
    rootComp=design.rootComponent

    planes = [p for p in rootComp.constructionPlanes]

    for plane in planes[::-1]:
        plane.deleteMe()
Message 3 of 4
peter.pant
in reply to: kandennti

Thanks for the hint, it works!
Message 4 of 4
j.han97
in reply to: peter.pant

Hi @peter.pant ,

 

Perhaps you could try this:

for plane in list(rootComp.constructionPlanes):
    plane.deleteMe()

 

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