Cancel
Showing results for 
Search instead for 
Did you mean: 

Assign value for User Defined Attribute

Experimenter
Experimenter

Hello everyone,

 

I try to auto assign value for a list of user defined attribue of object such as:

 

 

For i:=1 to n loop

For j:=1 to m loop

str_to_obj("A"+i+".B"+j) := 0;

next;

next;

In which:

-A: point to the path such as the transporter named "A'

-B: name o f the user defined attribute (Type: integer);

 

However, it doesnot work. Is there anyway to do it by a list or we have do it manually?

 

Thanks.

2 REPLIES

Re: Assign value for User Defined Attribute

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

you can use the method setAttribute and you need to transform the numbers to strings

 

For i:=1 to n loop
   For j:=1 to m loop
      str_to_obj("A"+to_str(i)).setAttribute("B"+to_str(j),0);
   next;
next;
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Assign value for User Defined Attribute

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello,

 

you can make this work by setting the atribute B with setAttribute in this way:

 

for var i := 1 to n
 for var j := 1 to m
  str_to_obj("A"+i).setAttribute("B"+j,0);
 next
next

Best regards,

 

Igor

Kind regards,

Igor
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution