Name of the top parent
-
Hi !
There is a component with what structure:Model
Top parent
|
parent
.
.
.
parent
|
childWhether there is a method to learn for "child" a name "Top parent"?
On an example "Generate Report" 1 column "PATH" shows a way to "child"
And if to take a name of a component 2 levels (a column "LEVEL") we learn a name "Top parent". If I have correctly understood that it is necessary to connect still a file dcclass_v1.rbs.
But what is necessary a code for reception of a name of a component 2 levels ("Top parent")?
-
IF you (or the user,) is in edit mode of Component#2, then:
Sketchup::active_model.active_path
will return an array of the nesting path.Otherwise
inst.parent()
returns the definition who's entities collection contains this instance.But, if the parent definition has multiple instances in the model,... which one of those instances is the one wrapping the lower instance ?
There may not be a way to tell ??
-
How Generate Report obtains this data without being in a mode of editing of a component?
-
Generate Report traverses the whole model from model.entities and traverse over everything in the model.
However, given an arbitrary component instance it's not possible to always get an exact hierarchy path to it's parents because it might be contained within multiple other instances - in which case you have ambiguity to what the correct result would be.
-
ok. I have understood it.
On image1 the way for the chosen component 5 is shown.
On image 2 the component 3 is allocated,
By means of a code I obtain the data for a component 1.any_attribute = entity.get_attribute ("dynamic_attributes", "any_attribute", 0).to_s
can I somehow temporarily make the component 1-active , will receive path, and revert to a previous state?
-
There is no way to change the active context in the Ruby API. You can only close it.
But it doesn't change the problem. If you have one component instance, there is is no way to knowing where it belong to.
Say we have a component "A". There is an instance of it in component "B". Say we have two instances of component "B": if we have a references to the instance of "A" it is impossible to tell which of the instances it belong to - because the very same instance of "A" exist at the same time in both instances of "B". Or to be more specific, An instance of "A" exist in the definition of "B". We can only trace the parent of "A" to the definition of "B" - not the instances.
Model ╠═B ║ ╚A ╚═B ╚A
You need context do determine where it belong to.
What is it you are making? What is the goal you are trying to achieve?
-
@tt_su said:
...What is it you are making? What is the goal you are trying to achieve?
I wanna make it
Advertisement