Component definition has TWO names ???

Component definition has TWO names ???

Postby Didier Bur » Thu Jul 18, 2019 8:14 am

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 ?


comp_display_name.jpg


Help TIG, Dan, Thomthom and all ruby gurus ;-)
0
Didier Bur
Ecole Nationale Supérieure d'Architecture de Nancy (F)
http://rld.crai.archi.fr/rubylibrarydepot/
User avatar
Didier Bur 
 

Re: Component definition has TWO names ???

Postby Gábor » Thu Jul 18, 2019 10:42 am

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?
0

Gábor 
SketchUcation IT
 

Re: Component definition has TWO names ???

Postby TIG » Thu Jul 18, 2019 2:35 pm

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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: Component definition has TWO names ???

Postby Didier Bur » Sun Jul 21, 2019 11:27 am

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...
0
Didier Bur
Ecole Nationale Supérieure d'Architecture de Nancy (F)
http://rld.crai.archi.fr/rubylibrarydepot/
User avatar
Didier Bur 
 

Re: Component definition has TWO names ???

Postby Dan Rathbun » Fri Sep 13, 2019 7:13 am

Didier Bur wrote:Sketchup.active_model.name is NOT (always) the same as the SKP file name...

Code: Select all
Sketchup.active_model.name
and
Code: Select all
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.
0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    SketchUcation One-Liner Adverts

    by Ad Machine » 5 minutes ago



    Ad Machine 
    Robot
     



     

    Return to Developers' Forum

    Who is online

    Users browsing this forum: No registered users and 4 guests

    Visit our sponsors: