cancel
Showing results for 
Search instead for 
Did you mean: 

Blank/Delete Entities in Modeling

Creator
Creator

Right now i've got car bodies with a lot of catia information, like text notes, which

affect the collisiontest.

 

Is there a possibility to get all entities of a modeled component?

I want to blank ot delete these elements via API.

 

Thanks in advance

 

3 REPLIES

Betreff: Blank/Delete Entities in Modeling

Valued Contributor
Valued Contributor

Hello, Titaniser,

You can find all child object of a component of a specific Type using the GetAllDescendants function of the class TxComponent. This function requires the parameter of the type TxTypeFilter, which gives you a possibility to specify which child objects have been returned. After that you can iterate through the returned objects and delete they with the method Delete.

 

Re: Blank/Delete Entities in Modeling

Siemens Legend Siemens Legend
Siemens Legend

Hi Titaniser,

 

As A-S-E suggested, you can use the GetAllDescendants method to search for entities within the component.

The yellow ones in the picture are PMIs - they are represented by the TxPmi class. But the PMIs should not affect the collision.

You can also control which types of PMIs should be loaded by Options dialog -> General Tab -> 3D Data Filtering ->PMI Types.

 

The other entities in the picture seem like points and polylines - TxPoint and TxPolyline. To make sure, you can check their type upon selection. Have in mind that there might be other polylines that should be included in the collision check. 

 

Best Regards,

DianaG

Re: Blank/Delete Entities in Modeling

Creator
Creator

If you know exactly type of object you can filter it using TxTypeFilter class,

Here example for delete wireframe which export from Catia,

 

public static void DeleteWireFrames(){
            try {
                ITxComponent comp = TxApplication.ActiveDocument.CurrentModelingWorkingSpace as ITxComponent;
                if(comp == null){
                    return;
                }
                TxObjectList list = (comp as ITxObjectCollection).GetAllDescendants(new TxTypeFilter(typeof(ITxGeometry)));
                TxObjectList solids = (comp as ITxObjectCollection).GetAllDescendants(new TxTypeFilter(typeof(ITx2Or3DimensionalGeometry)));
                if(list.Count == 0)
                    return;
                TxObjectList result = new TxObjectList();
                foreach(ITxObject obj in list)
                {
                    if(!solids.Contains(obj))
                    {
                        if(obj is TxKinematicLink)
                        {
                            
                        }
                        else {
                            result.Add(obj);
                        }
                    }
                }
                
                if(result.Count > 0)
                {
                    foreach(ITxObject obj in result)
                        obj.Delete();
                }
            }catch{}
            TxApplication.RefreshDisplay();
        }