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

    Get the Name attribute ( error )

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 311 Views 2 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.
    • G Offline
      goga63
      last edited by

      Explain where the error is?
      I create a component (a simple cube)
      And set attribute Name = test
      Save the file as test.skp and close Sketchup.
      Open the Sketchup file test.skp and enter in the Ruby Console code :

      model = Sketchup.active_model
      entity = model.selection[0]
      puts entity.get_attribute("dynamic_attributes","name","").to_s
      

      get the name of the component test. (image1)
      image1.jpg
      So far everything is fine.
      Next, I save a component from the context menu "Save As"
      Open a new file and load component cub from the menu Components
      Again enter in the Ruby Console the same code
      And get nothing. (image2)
      image2.jpg
      Why when loading a component of their menu Components
      code does not work ?
      however , the code :

      Sketchup.active_model.selection[0].definition.attribute_dictionary('dynamic_attributes').each_pair { |k,v| puts k + '; ' + v.to_s }
      

      correctly displays the name attribute of the component (among other attributes)
      image3.jpg
      In the General case I need the code displays the name attribute of the component.

      1 Reply Last reply Reply Quote 0
      • S Offline
        slbaumgartner
        last edited by

        I believe you are getting confused about the difference between a Component definition and instance. The dynamic_attributes dictionary is associated with an instance, not the definition. That's so that individual instances of the dynamic component can vary from one another according to these attributes. When you create a new instance from the Components window, it does not "inherit" dynamic_attributes assigned to other instances.

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

          The thing is that when downloading from the Components window real component I can get the values of any attribute (and there are about 20) except for the value of the Name attribute.

          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