sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Component definition has TWO names ???

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 4 Posters 6.9k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Didier BurD Offline
      Didier Bur
      last edited by

      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 😉

      DB

      1 Reply Last reply Reply Quote 0
      • G Offline
        Gábor
        last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          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...

          TIG

          1 Reply Last reply Reply Quote 0
          • Didier BurD Offline
            Didier Bur
            last edited by

            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...

            DB

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @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.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement