Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Delete previously created construction planes when running script

peter.pant
Participant

Delete previously created construction planes when running script

peter.pant
Participant
Participant

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!
0 Likes
Reply
Accepted solutions (1)
362 Views
3 Replies
Replies (3)

kandennti
Mentor
Mentor
Accepted solution

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()
0 Likes

peter.pant
Participant
Participant
Thanks for the hint, it works!
0 Likes

j.han97
Advocate
Advocate

Hi @peter.pant ,

 

Perhaps you could try this:

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

 

0 Likes