How can I use the mechanical script to locate these six locations and delete them?

sunyroy
sunyroy Member Posts: 11
First Comment Name Dropper
**


Thank you very much

Best Answer

  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 125
    100 Comments Second Anniversary 5 Answers Solution Developer Community of Practice Member
    ✭✭✭✭
    Answer ✓

    You can use DataModelObjectCategory to get category of objects and filter them. Here is an example for getting named selection with name 'Displacement'

    disp_ns =[ns for ns in ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.NamedSelection) if ns.Name=="Displacement"]

    You may not be able to delete object 1, which is a geometry.

Answers

  • sunyroy
    sunyroy Member Posts: 11
    First Comment Name Dropper
    **

    @Rajesh Meena said:
    You can use DataModelObjectCategory to get category of objects and filter them. Here is an example for getting named selection with name 'Displacement'

    disp_ns =[ns for ns in ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.NamedSelection) if ns.Name=="Displacement"]

    You may not be able to delete object 1, which is a geometry.

    Thank you very much for solving my problem. After searching on my own, I found that the script code for deleting part is

        geopartdel=ExtAPI.DataModel.GeoData.Assemblies[0].AllParts
        Model.DeleteParts(geopartdel)
    

    I hope it can help people who are also troubled by this problem. Please note that this script will delete all parts.

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 324
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    Adding to Rajesh's answer, you can get the object type by selecting a branch in the tree and running:
    Tree.FirstActiveObject.GetType()