question

Maciej avatar image
0 Likes"
Maciej asked Andrew O commented

How to set a different location for items from one input in combiner?

I want to model the process of mounting 2 elements with 4 screws. I have shaft (1st input in combiner), plate (2nd input in combiner) and 4 screws (3rd input in combiner). I am trying to put the screws inside the holes you can see below. Changing location of the plate is simple and it works:

it is done by trigger on entry - custom code:


Object current = ownerobject(c);

Object item = param(1);

int port = param(2);


if(port == 2) {

//setloc(item,1.71,-1.51,1.81);

setloc(item,-0.15,-0.13,0.77);

}


but I can not handle with changing position of any of the screws. Screenshot below.:

1669661375886.png

1669661724241.png

I was trying with that code (it doesn't work):

if (port == 3) {

for (int i = 1; i <= getvarnode(Model.find("Combiner1"),"componentlist").as(Table)[2][1]; i++) {

switch (i) {

case 1:

setloc(item.subnodes[i],0.16,-0.2,1);

setrot(item.subnodes[i],0,90,0);

break;

case 2:

setloc(item.subnodes[i],1.92,-1.42,2.01);

setrot(item.subnodes[i],0,90,0);

break;

case 3:

setloc(item.subnodes[i],2.07,-1.58,2.01);

setrot(item.subnodes[i],0,90,0);

break;

case 4:

setloc(item.subnodes[i],2.07,-1.43,2.01);

setrot(item.subnodes[i],0,90,0);

break;

default:

break;

}

}


I would be very grateful for your help :)

FlexSim 22.2.2
combiner input
1669661375886.png (184.4 KiB)
1669661724241.png (7.0 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.

Andrew O avatar image Andrew O commented ·

Hi @Maciej, was Dawid Dabal's answer helpful? If so, please click the "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

·
Dawid Dabal avatar image
1 Like"
Dawid Dabal answered

Hi Maciej,

It's tricky because of two things.

1. When OnEntry trigger is fired, flowitem that had entered Combiner from port != 1 is on the combiner, not on the cylinder, see the print screen below.

1669664114206.png

2. You can't sure in which order the flowitem will enter combiner after the first item (depends on availability and etc.)

You can bypass those issues with.

1. Using coroutines to delay the setlocation logic to the point when flowitem will be the child of the cylinder.

2. Using flowitem name to distinguish plate and screws to correctly set their location.

combiner_Placement.gifcombiner_location_2.fsm

Working model is attached, code is in the OnEntry trigger on combiner.


5 |100000

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

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.