set_attribute problem

set_attribute problem

Postby Pixero » Thu Jan 16, 2020 11:56 am

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

Code: Select all
@myid = e.definition.get_attribute("A", "Id") 


If I do a:
Code: Select all
puts @myid

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

And setting it this way:

Code: Select all
e.definition.set_attribute("A", "Id", @myid)

or
Code: Select all
e.definition.set_attribute("A", "Id", @myid.to_s)   


But all I get is nil.

What am I doing wrong?
0
User avatar
Pixero 
 

Re: set_attribute problem

Postby TIG » Thu Jan 16, 2020 1:28 pm

If you use this code in your script, then what do you see in the Ruby Console when it runs ?
Code: Select all
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 ??
0
TIG
User avatar
TIG 
Global Moderator
 

Re: set_attribute problem

Postby Pixero » Thu Jan 16, 2020 1:32 pm

Then I get:

Code: Select all
{@myid}


I'm doing it inside a:

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


Edit:

Doh! :oops: It was all a small typo with a D instead of a d.
Works as it should now.
1
User avatar
Pixero 
 

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 6 guests

Visit our sponsors: