question

Zixuan Xiong avatar image
0 Likes"
Zixuan Xiong asked Phil BoBo edited

Object Visual refresh during model runing

change-visual-sample-model.fsm

If we use either process flow or custom code to change the visual of certain objects, the visual look for the objects would not refresh during the model running. This problem also exists for rack, task executer, etc.

@Sam Stubbs @phil.bobo

FlexSim 17.1.2
object visual
5 |100000

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

1 Answer

Phil BoBo avatar image
3 Likes"
Phil BoBo answered Phil BoBo edited

In this model, you are changing the size of an object whose shape is defined by subcomponents in the Animator.

You can use the following code line to have an object to resize its subcomponents based on its size:

applicationcommand("resizesubcomponents", object);

If you put that code after setting the size, this model will behave as you expected.

(See also How to scale the drawsurrogate objects?)

The Rack draws itself using custom draw code based on its SizeTable tab that defines the number and width of bays and the number and height of levels. It doesn't draw itself based on its size. You can return 1 in its Custom Draw trigger if you don't want it to do its default draw code.

· 4
5 |100000

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

Zixuan Xiong avatar image Zixuan Xiong commented ·

Hey Phil! @phil.boboThanks for your answer. That works for me and here below is my code. I change every subcomponent's spatial and spatial size one by one and visual look behave as I want. Because I actually only want the yellow box for the truck object to resize not the actual components.

Is there a better way to do this?

And for rack, if we change the SizeTable tab during the model, how can we call the drawing process? Can you explain more on "You can return 1 in its Custom Draw trigger if you don't want it to do its default draw code."?

Object truck = token.truck;
Object SemiCab = drawsurrogate(truck).subnodes["SemiCab"];
Object FrontWheels = SemiCab.subnodes[1];
Object RearWheels1 = SemiCab.subnodes[2];
Object RearWheels2 = SemiCab.subnodes[3];

setsize(truck, 268,84,105);
applicationcommand("resizesubcomponents", truck);
spatialx(SemiCab).value = 0;
spatialz(SemiCab).value = 7;
spatialsx(SemiCab).value = 248;
spatialsy(SemiCab).value = 84;
spatialsz(SemiCab).value = 105;
spatialsx(FrontWheels).value = 29.05;
spatialsy(FrontWheels).value = 76;
spatialsz(FrontWheels).value = 28;
spatialx(FrontWheels).value = 193.66;
spatialy(FrontWheels).value = -4;
spatialz(FrontWheels).value = -7;
spatialsx(RearWheels1).value = 29.05;
spatialsy(RearWheels1).value = 76;
spatialsz(RearWheels1).value = 28;
spatialx(RearWheels1).value = 44.61;
spatialy(RearWheels1).value = -6;
spatialz(RearWheels1).value = -7;
spatialsx(RearWheels2).value = 29.05;
spatialsy(RearWheels2).value = 76;
spatialsz(RearWheels2).value = 28;
spatialx(RearWheels2).value = 5.19;
spatialy(RearWheels2).value = -6;
spatialz(RearWheels2).value = -7;
0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Zixuan Xiong commented ·

You can call setSize() and setLocation() directly on those objects. You don't need to set the value of the attributes one by one:

SemiCab.setLocation(0, SemiCab.location.y, 7);
SemiCab.setSize(248, 84, 105);

"And for rack, if we change the SizeTable tab during the model, how can we call the drawing process? Can you explain more on "You can return 1 in its Custom Draw trigger if you don't want it to do its default draw code."?"

You don't change the values in the SizeTable tab during the model. I was explaining that the Rack's draw is based on the variables on the Rack that are modified using the SizeTable tab, not based on its size. You shouldn't dynamically change the Rack's SizeTable during the model run.

The objects that are drawn via OpenGL code rather than an imported shape can have their draw disabled by returning 1 in the Custom Draw trigger:

0 Likes 0 ·
Zixuan Xiong avatar image Zixuan Xiong Phil BoBo ♦♦ commented ·

I thought we are deprecating setsize and setloc... Nevermind I will use this.

The rack question is actually for another project. I imported a rack info excel file into flexsim using tables and autopopulated a lot of rack object based on that. In order to do that, I have to create the rack object first and update the sizetable tab based on the rack info table. That's why I need to redraw the rack during the model. Is there any workaround for this?

0 Likes 0 ·
Show more comments