Hey all, happy Monday! Trying to figure out how to check if a selected parent component has a bottom level child component (number of nesting levels changes) with xxx attribute. Any ideas, is this possible?
something like this:
def find_attr(ents, mydict, myattr)
ents.grep(Sketchup::ComponentInstance){|inst|
return inst if inst.get_attribute(mydict, myattr)
find_attr(inst.definition.entities, mydict, myattr)
}
nil
end
def attribute?(mydict, myattr)
model = Sketchup.active_model
selection = model.selection
inst = selection.grep(Sketchup::ComponentInstance).first
return unless inst
ents = inst.definition.entities
first_comp_with_attr = find_attr(ents, mydict, myattr)
end
attribute?("mydictionary", "myattribute")
1 Like
Thanks @dezmo!
1 Like