How to delete Edges of some components in SpaceClaim?
Ayush Kumar
Member, Moderator, Employee Posts: 442
✭✭✭✭
Best Answers
-
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)
2 -
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
0
Answers
-
How to modify this code, if we have to remove stray lines from any general component?
0 -