DC - hidden parts
-
How can I recogize a DynamicComponent? I guess I can look for a certain attribute, right?
Is there a way in Ruby to recognize which part of a DC is currently not being displayed? -
@unknownuser said:
How can I recogize a DynamicComponent? I guess I can look for a certain attribute, right?
def is_a_DC?( obj ) obj.is_a?(Sketchup;;ComponentInstance) && obj.definition.attribute_dictionary("dynamic_attributes") end
@unknownuser said:
Is there a way in Ruby to recognize which part of a DC is currently not being displayed?
ents = obj.definition.entities.to_a ehid = [] ents.each {|e| ehid<<e if e.hidden? }
-
@dan rathbun said:
obj.definition.attribute_dictionary("dynamic_attributes")
Thanks!
@dan rathbun said:
ents = obj.definition.entities.to_a
ehid = []
ents.each {|e| ehid<<e if e.hidden? }I have to check this, but I test all entities visibility with
.visible?
and this doesn't work in components like a door with several wing types.
hidden?==!visible?
?
I have the attribute dictionary anyway. I can dig deeper now. -
Components can contain nested Groups and other Components. The Components could be normal or dynamic.
If nested, you'll need to do a recursive search (make a search method that calls itself.)
-
I believe there is a fundamental bug in the .visible? method.
If you walk the hierarchy and query an entity.visible? state, it simply tells you whether it has explicitly been hidden, not whether it is visible.. very un-useful!
You would need to follow the hierarchy all the way to the top to determine if any antecedent (parent) was hidden - and thus all subsequent children are hidden - to get the correct answer.
Basically it requires you to structure code as a recursive descent.. which runs counter to the definition.instances graph-like structure.
EDIT: as I'm writing this..are you saying hidden? and visible? are actually different?
-
@dan rathbun said:
Components can contain nested Groups and other Components. The Components could be normal or dynamic.
If nested, you'll need to do a recursive search (make a search method that calls itself.)Dan, I am an author of two exporters , I have learned it few years ago. SU2Thea exports whole SU model hierarchy.
@adamb said:
You would need to follow the hierarchy all the way to the top to determine if any antecedent (parent) was hidden - and thus all subsequent children are hidden - to get the correct answer.
Basically it requires you to structure code as a recursive descent.. which runs counter to the definition.instances graph-like structure.I do walk all the hierarchy from the very top till the last
visible?
entity. It works perfectly on all objects. SU2Thea exports everything fine except this door for example:The door has several layouts of a door leaf defined. They are all being exported, because when I check
e.definition.entities
all returntrue
although not all are being visible on a screen at the same moment in the same instance.I guess I have to recognize whether I have a DC, then check which option has been chosen for the instance I investigate
(probably an attribute)
and then discard all faces in a definition that doesn't belong to the 'option'(I guess defined in an attribute of the instance again)
.I hope that is easy to distinguish parts of DC definition that are optional. If it isn't obvious from attributes that a DC stores then.. it will be hit or miss.
@adamb said:
EDIT: as I'm writing this..are you saying hidden? and visible? are actually different?
I was asking Dan whether there is a difference, but I doubt. API Docs don't mention it.
I will dig into the issue. I just thought someone has already been there.
Advertisement