After developing dynamic components for a few months I’m diving into Ruby coding to learn to manipulate geometries more effectively. I am currently reading Ruby guides and Sketchup Ruby API, but couldn’t find a solution to my problem, and decided to ask help to the community.
My model is composed of several components, and each is composed of 3 groups named LOD0, LOD1 and LOD2 that contain geometries of the component with different level of details. LOD0 is a really simple shape like a bounding box, and LOD2 contain the fully detailed geometry (with screws, holes, notches and stuff). LOD1 is in-between.
During manipulations and experimentation with my beginner-Ruby-scripts it appeared that I accidently deleted LOD0 and LOD1 in some of the components. This cause some of my previous scripts to fail.
Simple example of my model structure. The CUBE_2 component misses LOD0 & LOD1, causing trouble.
I don’t want to spend hours looking for each items in my model to retrieve the ones with missing LODs and repairing them, so I want to write a script in Ruby to retrieve the components in my model that contain less than 3 groups, and duplicate/renaming the still existing LOD2 in order to retrieve the LOD0, LOD1 & LOD2 original structure for each component (doesn’t matter if all 3 LODs are the same).
The thing is, I can’t find a way to inspect each instance in my model and count/manipulate the groups inside.
Is this due to the particular nature of groups in SU ? Or simply to my lack of experience in Ruby coding ? Is there a method or a trick I don’t know yet that could help me solving this ? Do I have to explode everything in my component and recreate groups ?
Thank you very much for your help !