Atom attributes initialization

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
nfiguera
Posts: 3
Joined: Thursday 26 April, 2012 - 11:35

Atom attributes initialization

Post by nfiguera »

Hi,

I want to implement a routine to initialize certain attributes of my model using data from a table.

Code: Select all

For ( 
var([icount], vbvalue, 0), 
icount <> nrows (equipment(1,1)), 
setatt(1,equipment(icount,2),
atombyname(equipment(icount,1))),  
inc(icount)
)
Sadly, the function atombyname is not recognizing the names in the table, which is strange as they are copied directly from the atoms gui.

Is there any safer way to do this? what is that I am missing?

Thanks in advance,

Noel
User avatar
MatthijsJongboer
Posts: 200
Joined: Thursday 11 November, 2010 - 14:12

Re: Atom attributes initialization

Post by MatthijsJongboer »

Hi Noel,

There are several ways to initialize your model. Indeed, a table (possibly linked to excel) is a good way of having your parameters in a central location. Furthermore, you can also choose to use the initialize atom or reference the table cell in the attribute.
You could have a table (e.g. with named alias startsettings) that has the required setting in cell 1,1.
On the attribute (e.g. cycle time for a server) you can then write startsettings(1,1).

It seems to me you want to list in your table the name of the atom with it's definable parameters.
You can do this using AtomByName but for that you require a second parameter (AtomByName(equipment(icount,1),Model)).
nfiguera
Posts: 3
Joined: Thursday 26 April, 2012 - 11:35

Re: Atom attributes initialization

Post by nfiguera »

Thank you,

That worked !

Best,
Post Reply