• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Set_attribute problem

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 6.2k Views
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.
  • P Offline
    Pixero
    last edited by 16 Jan 2020, 10:56

    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
    • T Offline
      TIG Moderator
      last edited by 16 Jan 2020, 12:28

      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
      • P Offline
        Pixero
        last edited by 16 Jan 2020, 12:32

        ~~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
        1 / 1
        • First post
          1/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement