Ruby api: reference point within a component
-
Hi there,
have a question, could not find elegant answer by myself, could be useful for others as well, so experts please help:
imagine you have two component definitions C_outer and C_inner, an instance of C_inner is part of C_outer. For example C_outer is a house and C_inner is a door. We also have a reference point in C_inner's geometry, for example the center of the keyhole, that we want to use later to align other objects, for example to place a key into the keyhole.
So if I create multiple instances of C_outer, i.e. multiple houses, how can I easily find the position of the keyhole of a given house? (I could retrieve the position of the house instance via ComponentInstance::transformation, but I will also need the transformation of the door, for which I first needed to find the door instance among the entities of the house which is quite cumbersome - is there a nicer way?)
Hope the question is clear, tell me if I should elaborate more!
Thx,
Balazs -
@torel said:
(I could retrieve the position of the house instance via ComponentInstance::transformation, but I will also need the transformation of the door, for which I first needed to find the door instance among the entities of the house which is quite cumbersome - is there a nicer way?)
That's how you do it - you need to combine all them transformations.
-
Yes you do not need to search among ALL the house's entities, IF you know the door's definition.
IF you do, then simply look in the definition's
instances()
collection.If there are multiple door definition's, then you can iterate the model's
DefinitionList
collection, testing each definition for some identity (name value, or attribute in an attribute dictionary, etc.,) ignoring any definitions that have no instance, ie:
!defn.instances.empty?
Advertisement