How to delete Edges of some components in SpaceClaim?

Options
Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 411
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
edited June 2023 in 3D Design

How to delete Edges of some components in SpaceClaim?

Tagged:

Best Answers

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 411
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    Answer ✓
    Options

    In case you have projected edges on a Sphere (screenshot below) and there are numerous spheres in the assembly, you could use the following:

    spheres = []
    for component in GetRootPart().Components:
        """
        Selecting the right components based on some condition.
        In my case only first 2 components are not spheres which are
        named 'Component1', 'Component2'. Hence, I select everything
        but these two.
        """
        if component.GetName() not in ["Component1", "Component2"]:
            spheres.append(component)
            
    edges = []
    for sphere in spheres:
        sphere_edges = sphere.GetAllBodies()[0].GetDescendants[IDesignEdge]()
        edges += sphere_edges
    
    edges_selection = Selection.Create(edges)
    Delete.Execute(edges_selection)
    

    enter image description here

  • Valérie Gelbgras
    Valérie Gelbgras Member, Employee Posts: 156
    Photogenic First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓
    Options

    For the component selection, we can generalize your code.

    In the function defined below, we filter out the component by their name. The first argument of the function is a list of names to exclude. The second argument is optional with a default value False. When it is False, the filtering is done on all components and sub components. When it is True, the filtering is done on the root components.

    def filter_out_components_by_name(componentNameToExclude, onlyRootComponents=False):
        components =  GetRootPart().Components if onlyRootComponents else  GetRootPart().GetAllComponents()
        components = [component for component in components if component.GetName() not in componentNameToExclude]
        return components
    
    nameToExclude = ["Sample Block A", "Sample Block B"]
    test1 = filter_out_components_by_name(nameToExclude, True)
    test2 = filter_out_components_by_name(nameToExclude)
    

    For the edge, we also do:

    sphere.GetAllBodies()[0].Edges
    

Answers