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

    Set_attribute problem

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 6.2k 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.
    • PixeroP Offline
      Pixero
      last edited by

      I'm getting an attribute from a component this way:

      @myid = e.definition.get_attribute("A", "Id")  
      

      If I do a:

      puts @myid
      

      I get the correct value.
      Something like this: 0481e69d-cbc0-4e4c-2c32-e2d2f7932bdf

      And setting it this way:

      e.definition.set_attribute("A", "Id", @myid) 
      

      or

      e.definition.set_attribute("A", "Id", @myid.to_s)   
      

      But all I get is nil.

      What am I doing wrong?

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

        If you use this code in your script, then what do you see in the Ruby Console when it runs ?

        puts"{@myid}"; e.definition.set_attribute("A", "Id", @myid)
        

        Remember that @myid will probably not be accessible in the Console, as I suspect that it's being set within your own method ??

        TIG

        1 Reply Last reply Reply Quote 0
        • PixeroP Offline
          Pixero
          last edited by

          ~~Then I get:

          {@myid}
          

          I'm doing it inside a:

          sel.each {|e|
            puts"{@myid}"; 
            e.definition.set_attribute("A", "Id", @myid)     
          }
          

          ~~

          Edit:

          Doh! 😳 It was all a small typo with a D instead of a d.
          Works as it should now.

          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