cancel
Showing results for 
Search instead for 
Did you mean: 

create new MU

Creator
Creator

Hi

If I use init method to download information into the table abouth length and width, how can I create obejct with length and width such as in table?

Regards

9 REPLIES

Re: create new MU

Phenom
Phenom

you could run through the table using an loop, create an MU and set width and length according to the data in the table rows e.g: if your width is in column2 and length in column 3 the syntax could look like this (new syntax)

 

var part : object

 

for var i:=1 to tableFile.yDim loop

   part:= .MUs.Entity.create(YourDestination)

   part.MuWidth:=tableFile[2,i]

   part.MuLength:=tableFile[3,i]

next 

 

the columns with width and length should have the data type real


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


Re: create new MU

Creator
Creator

I do it that but something is wrong, and this method will create object called "Entity", but if I want name from first column, should I add??

part.MuName:=DataTable[1,i];


Regards



Re: create new MU

Phenom
Phenom

first, if  you want to create a certain number of parts then you cannot use the source as destination, use instead e.g. a buffer

 

The attribute for setting the name is "name". For creating the number of parts from column 2 of your DataTable, you need a second loop e.g.

 

for  i := 1 to DataTable.yDim loop
	for k:=1 to DataTable[2,i] loop

	 	part:= .MUs.Entity.create(buffer);
   		part.MuWidth:=DataTable[5,i];
		part.MuLength:=DataTable[6,i];
		part.name:=DataTable[1,i]
	next;
next; 

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


Re: create new MU

Creator
Creator

Great, thank you for help. 
If I want add to this table next column with information about color, information in table should be integer ? Is it even possible ? Or Should I create method when e.g. if "red" then:

part.color:=makeRGBValue(255,0,0);

but that is wrong.


Regards

Re: create new MU

Phenom
Phenom

if you work with the vector graphics, the command is:

 

vectorGraphicsColor

 

e.g.

 

part.vectorGraphicsColor:=makeRGBValue(255,0,0);


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


Re: create new MU

Creator
Creator

So only otion is?:

	if DataTable ["color", j] = "red" then
		part.vectorGraphicsColor:=makeRGBValue(255,0,0);
	else
		...
	end;


Regards

 

Re: create new MU

Phenom
Phenom

if you deactivate the vector graphics, you can add icons to the MU and name them ("red","green"), Then you can use

part.currIcon:=DataTable ["color", j]

to show the right Icon.

 

If you edit your table manually, you can also set the background color of the table cell with the color you need. Then you can read this background color and set it als MU color:

 

part.vectorGraphicsColor:=DataTable.getBackgroundColorCell("color", j);


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


Re: create new MU

Creator
Creator

So if I wont to take information about color from table1 to table2 I should:

Table2.backgroundColorCell("color", i);:=Table1.getBackgroundColorCell("color", i); ??



Regards

Re: create new MU

Phenom
Phenom

I you want to transfer the cell colors between two tables, you need:

 

table2.setBackgroundColorCells({"Color",i}..{"Color",i},
     table1.getBackgroundColorCell("Color",i))

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