TAGGED: Moderator Discovery Geometry, scripting
-
-
July 25, 2025 at 7:30 am
p.vintr
SubscriberHello, I would like to ask experienced users a question.
Is it possible to use a script(# Python Script, API Version = V251) to find models that are inside other models and then subtract them?It's about ajdustin cabinets parts, where are joints represented by model. see simple example.
Â
I want to find all inner models and remove them and before subtract them from whole panel.
Now I am able to go through parts in document, but I cant find the way how create condition for it.
Thank you for any answer.
Â
Kind Regards.
Pavel
-
July 25, 2025 at 11:19 am
Atharv Joshi
Forum ModeratorHi Pavel,Â
You can record the operations in SpaceClaim/Discovery.Â
Activate the script editor and use Interference tool from Prepare Tab.That should find and fix all the interference in the geometry.Â
It will also record the command or API used.You can fix all the interference and also use for removing between specific selections.
If you want to the interference to be removed from smaller body, then you need to select it from options.Thanks and Regards
Atharv -
July 29, 2025 at 8:02 am
p.vintr
SubscriberHI,
thank you for your reply.
I know about recording the procedure.
What I can't figure out is how to use a loop to go through all the models in the drawing and subtract the models defining the hole from the large piece.Â
The image of the part I sent is only part of the entire assembly; it will be a kitchen with many more components. If this can be solved, the customer will probably purchase SpaceClaim.I didn't mention that I am a SpaceClaim sales representative in the Czech Republic.
Thanks for any help.
Kind Regards.
Pavel
Â
-
July 30, 2025 at 7:04 am
NickFL
SubscriberÂ
Hello p.vintr,
I am not exactly sure what you mean by models. You should be able to create loops over the different components within the model. For example:
Â
numberOfComponents = GetRootPart().GetAllComponents().Count
for component in GetRootPart().GetAllComponents():
 for body in component.GetAllBodies():
   print(component.GetName(), body.GetName())
  print(‘new Component’)Â
Note this will not evaluate bodies that are directly under the RootPart, only those in a component. If I am miss reading your question, please let me know and I am sure there is a solution. If you could show the structure tree from an example problem, that would help.
Â
-
-
July 30, 2025 at 8:23 am
p.vintr
SubscriberHi Nick,
thank you so much.
The target is to make subtract of the models(bodies) which are all of their volume inside the another (its cabinet's parts).
Â
It's simplyfy for one part but in the reality there will be a lot of them. This is one cabinet from the customer as example. Whole kitchen will be here in future.
Â
Kind Regards.
pavel
Â
Â
-
July 30, 2025 at 8:40 am
NickFL
Subscriber- Is there a naming convention that will ALWAYS be there? It looks like you have that Pevne is removed from Telesco. Will that always be the case?Â
2. These will be in the same component, correct?Â
Â
-
July 30, 2025 at 9:30 am
-
July 30, 2025 at 8:53 am
Atharv Joshi
Forum ModeratorHi Pavel,Â
You can create selection based on the geometry name, through named selection or use geometric details like volume etc
Let’s assume that the parts have name plate and cylinder always.You can make selections using the names, volumes (cubic meter) as shown below.
Then execute the delete operation on the selection.Regards
Atharv-
July 30, 2025 at 10:34 am
p.vintr
SubscriberHi, I also thought about filtering by volume, but I'm not sure if that will be sufficient, because the elements will be different. I would like to be able to evaluate whether one model is inside another.
-
July 30, 2025 at 10:46 am
NickFL
SubscriberIt seems like most of your bodies are planar/cylindrical. In that case you could compare the bounding boxes to see if they overlap. With more generic shapes the bounding boxes could overlap but not the bodies themselves which could cause problems when you try and subtract them.Â
-
July 31, 2025 at 7:04 am
NickFL
SubscriberIf you wanted to use the interference command like you had earlier, try something like this:
for component in GetRootPart().GetAllComponents():Â
  # Activate the current component
  sel = ComponentSelection.Create(component)
  result = ComponentHelper.SetActive(sel,None)
  Â
  # Use Interference to create holes in larger Body
  sel = Selection.Create(component.GetBodies())
  FixInterference.FindAndFix(sel)
-
-
-
- You must be logged in to reply to this topic.
-
3572
-
1118
-
1063
-
1050
-
952
© 2025 Copyright ANSYS, Inc. All rights reserved.