Cancel
Showing results for 
Search instead for 
Did you mean: 

write in table via method

Creator
Creator

hi pml-folks.

 

I want to write the coordiantes (x/y) of my assembly station (it is only 1 so far) in a table via a method.

i was able to print the coordinates in my console but it is not working in a table. this is because the value of the coordinates is (integer) and i only can write (string).

 

is there any possibily to convert my integer? or any other way to write my coordinates in a table?

 

thanks in advance

 

6 REPLIES

Re: write in table via method

Creator
Creator

ok.
I was able to convert my table. now my values get written in the expected cell.
the name of my station and the coordinates.

 

now the problem i have is that i want to automize it. 

so that every station i add to my scene gets added to the list via method.

i never read anything about a certain command which addresses all the stations. i am only able to call them via their names, which is too much work for huge scenes.

Re: write in table via method

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

click with the right mouse key on the head of a table column; you can assign each column a data type e.g. first collumn string, second and third column integer.

Than you need ony one line simtalk to write one line:

 

tableFile.writeRow(1,tableFile.yDim+1,obj.name,obj.xDim,obj.yDim)

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: write in table via method

Creator
Creator

dear Steffen,

thanks for your fast answer.

the problem i now have is, that i have to add all names of my objects... as i understand it..

But if it is possible i want a code which recognizes all objects i added to my scene automatically so i won't have to call them by their names. the name is my 3rd output.
This is because i will have large scenes with a lot of objects where it will be too much work to add the names.


for example.

IS
positionX : integer
positionY : integer

DO
for all objects
Tabelle[1,ydim+1]:=object.Name;
Tabelle[2,ydim+1]:=positionX;
Tabelle[3,ydim+1]:=positionY;
END;

Re: write in table via method

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

have a look in the method node(<integer>) and numNodes

 

your method could look like this (SimTalk 2.0)

 

var i:integer

var obj: object

 

for i:=1 to root.numNodes loop

  obj:=root.node(i)

  yourTable.writeRow(1,yourTable.yDim+1,obj.xPos,obj.yPos,obj.name)

next

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: write in table via method

Creator
Creator

dear Steffen,
with your help i am able to write my x and y coordinates in a table.
so far everything works perfectly. i can add and delet objects and my method recognizes my actions.

a little tweek i want to implement is an update.
right now i execute my method. it starts a table and adds rows.
but if i change my scene and move my objects, it also adds rows and my table will look like this:

METHOD
obj1 x y
obj2 x y
obj3 x y
METHOD
obj1 x y
obj2 x y
obj3 x y
updated obj1 x y
updated obj2 x y
updated obj3 x y
obj4 x y

the goal is to update my objects
for example

obj1 x y
obj2 x y
obj 3 x y
METHOD
updated obj1 x y
updated obj2 x y
updated obj3 x y

obj4 x y



Re: write in table via method

Creator
Creator
ok i just added a small "table.delet" in front of my code and everything works perfectly


thanks steffen!!

with regards