Selecting dynamic components by their components options

I have dynamic components for cabinets.
In Sketchup, is there a way to select the dynamic components based on their value in components options?

The conditions would be like an object w/ A_ItemCode equal to 33 or any objects w/ B_CarcassWidth greater than 800mm.

This could be done with Ruby…

model = Sketchup.active_model
sel = model.selection
dict = 'dynamic_attributes'
code33 = []

sel.each do |dc|
  check = dc.get_attribute( dict, 'item_code')
  if check == '33'
    code33 << dc
  end
end

sel.clear
sel.add code33

test.skp (98.4 KB)

2 Likes

Thank you!

Will you please give some suggestions on how and where to learn Ruby and Sketchup API?
Because there are many more ideas I want to explore now that I see the power of programming from your answer.

Liked I want to align the selected dynamic components on x-axis with like 10cm distances w/ each other. I think Ruby and Sketchup API can help but no idea where to start.

1 Like

After debugging process, I found that Ruby uses lowercases.

1 Like
2 Likes

Glad it worked for you! @rtches link to Dans resources is a great place to start, and you can always search and post here with questions. It’s a pretty steep learning curve and it can be quite a bit of fun too…

1 Like