question

Gilana P avatar image
0 Likes"
Gilana P asked Jeanette F commented

Code to define location

Hey!


this is my code for the operator to become an operator carrying a pallet truck

When the box is size X, it is centered and ok. When it is smaller than X, it is visually out of the pallet truck. How can I correct this code so that the pallet truck loads both types of boxes in the correct x, y, z positions?


/**Custom Code*/

Object item = param(1);

Object current = ownerobject(c);

Object station = param(2);

setrot(item,0,0,90);

setloc(item,1,0.32,0.13+(current.subnodes.length-1)*item.size.z);



What if I want the boxes to be evenly distributed instead of being stacked in a single row using the same code as above?


FlexSim 21.1.2
processflowflowitemflexsim 21.1.2globaltablecostum code
1622486613244.png (158.1 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Gilana P, was Joerg Vogel's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Gilana P commented

Perhaps you take a look into the manuell where you can adjust the point of origin of an object. You can set this reference point inside the parameters of the methods getLocation and setLocation. The default point of reference is the upper left corner of bottom most surface. If you set your reference point to lay on the middle line in y-direction of the size of your item, then it is getting a bit easier to compute the location. You can even use the same location like

nextItem.setLocation(prevItem.getlocation(1,0.5.0), Vec3(0,0.5,0))

nextItem and prevItem are just names to describe the references of involved items. Vec3( x,y,z) is a constructor for a Vec3 class object.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Gilana P avatar image Gilana P commented ·

Thank you!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.