Component definition has TWO names ???
-
Anyone ever noticed that a component definition has TWO names ?
Just like materials, it seems to me that there is a definition "real" name AND some sort of "display name".
Look at the picture below: internally the component definition is named "Plant_Umbrella" and it appears in the infos palette under "Plante_parapluie" ("parapluie" is the french word for "umbrella")
The ComponentDefinition class doesn't have a "display_name" method like the Material class do.So the question is: is there a way to retrieve the display name ?
Help TIG, Dan, Thomthom and all ruby gurus
-
I don't have the answer as I'm not a SketchUp guru. But I have a layman's question: How did you achieve this "double name"? Could you please attach an .skp with such a component definition in it or describe how to create one?
-
A SKP uploaded which shows this would be helpful...
I haven't ever seen this.
But you can have a component that starts off being 'external' and is renamed after insertion.
Let's say its external SKP is named
"XXX.skp"
.
You import it...Sketchup.active_model.selection[0].definition.name >>> "XXX" File.basename(Sketchup.active_model.selection[0].definition.path, ".*") >>> "XXX"
Rename the component as
"ZZZ"
Sketchup.active_model.selection[0].definition.name >>> "ZZZ" File.basename(Sketchup.active_model.selection[0].definition.path, ".*") >>> "XXX"
But I see no equivalent of name / display_name, as with materials...
-
Thanks TIG for the explanation. I also noticed the "path" and "rename definition" tricks.
BUT what I discovered is the following:If a component was imported from a path that doesn't exist anymore on you system, even if you rename its definition, Sketchup.active_model.selection[0].definition.name will output the imported SKP file name, and you cannot retrieve the new definition name.
Strange behavior, isn't it...In fact:
The component definition name is NOT ALWAYS the name of the SKP you imported to use that component:
- import a component, say A.skp, containing a red cube
- select it and type Sketchup.active_model.selection[0].definition.path, you'll get, say c:\Users\TIG\DeskTop\A.skp
- BUT Sketchup.active_model.selection[0].definition.name will output, say: Red cube
- open the A.skp file in Sketchup
- Sketchup.active_model.name will output, say: Red Cube
Sketchup.active_model.name is NOT (always) the same as the SKP file name...
-
@didier bur said:
Sketchup.active_model.name is NOT (always) the same as the SKP file name...
Sketchup.active_model.name
and
Sketchup.active_model.description
are used to set the name and description when you will be using the entire file as a component.
Secondly, these 2 fields are used to set the name and description that will be displayed when using the file as a template.
So it seems that someone who saved the file, renamed it using francais and resaved it under the old english filename.
There are cases when the filename (minus extension) are used to set the component name. Importing an image is one case.
Advertisement