ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 11-22-2007
Iulian Marin Ion Iulian Marin Ion is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 14
Downloads: 53
Uploads: 0
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 155
Iulian Marin Ion is on a distinguished road
Default Dynamically assigning 3D shapes to flowitems

Very simple question. I am trying to change the 3D shape of a flowitem at the exit of a process, but I cannot determine the flowitem's index (as recommended by the picklist option) since the list from Tools – Media File does not shows the flowitems that I have defined.

I have built a simple model with a source generating my desired flowitem and printed the shape index with pf(getshape …). I have obtained -4 (on output console) but when using back that index shape to my model …. nothing goes as expected. Am I doing something wrong?

The Tools - Media File does not shows the index shape of the custom flowitem I am looking for. The attached file try to shows some more details.
Attached Files
File Type: doc Very simple question.doc (80.5 KB, 414 views)

Last edited by Cliff King; 11-22-2007 at 08:14 PM.
  #2  
Old 11-22-2007
Cliff King's Avatar
Cliff King Cliff King is offline
Vice President Technical Services
 
Join Date: Jul 2007
Location: Utah
Posts: 272
Downloads: 158
Uploads: 14
Thanks: 102
Thanked 304 Times in 110 Posts
Rep Power: 412
Cliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud of
Default

You have misunderstood the purpose of the Tools>Media Files menu option. It's purpose is to allow you to preload (import into Flexsim) 3D shapes and 2D images from external files for the purpose of referencing the imported media by an index that is assigned to the media automatically by Flexsim during the import process.

Normally if you browse and assign media to an object in your model or to a flowitem through the Properties window interface, the media will get loaded at that time and you do not even worry about an index reference. However when you want to change the 3D shape of a flowitem on-the-fly using a trigger like you are attempting to do, it's necessary for you first to preload the media using Tools>Media Files.

When you first open the preloader with Tools>Media Files, it defaults to showing "Shapes", however you can also choose "Images" from the top dropdown list. If you click on the little black down arrow on the next dropdown list, you will see all of the media that is currently loaded into Flexsim of that type (either shapes or images).

You need to click on the Browse button to find the 3D file you want to import. After choosing your file and hitting "Open", the file name will appear in the lower field and you will need to press the Add button to actually import the 3D file. Now you need to click on the little black arrow again to see what index was assigned to your imported shape. This is the number you will need to use in the OnExit trigger picklist option you original tried to use. One thing to keep in mind, is that these automatically assigned index numbers for imported media are dependant upon the order they were loaded when Flexsim was started and your models were loaded. Sometimes new Flexsim releases will include different objects and/or media so that the media loading sequence is different. So in other words the index that used to point to a balloon, may now point to an icecream cone!
  #3  
Old 11-23-2007
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default Find Shape Index

Guys,

Yesterday I exactly worked on this kind of stuff and I am not sure, but it seems to be that some of the commands are not working or I do something wrong.

I put a Visual Tool in my model, named it ‘Operator’, set it to Imported Shape and gave it the ‘fs3d\Operator.3DS’ shape. So it looks like an operator.
If I check in the tree under visual the shape node is ‘fs3d\Operator.3DS’ and the shapeindex is ‘7’ what looks correct.

I make the operator so() and do some script commands:
getname(so()); Returns: Operator Correct.
Just to check if so() is correct.
getobjectshapeindex(so()); Returns: 7 Correct.
Just to check.
getshapeindex("fs3d\\Operator.3DS"); Returns 7 Correct.
Just to check.
setobjectshapeindex(so(),1); Returns: 0 Correct.
Just to give another shape (fs3d\FlowItem.3DS)
setobjectshapeindex(so(),getshapeindex("fs3d\\Oper ator.3ds")); Returns: 0 Failure!
No shape given to the object. Example from the Flexsim Command Reference.
getshapeindex("fs3d\\Operator.3ds"); Returns 0 Failure!
getnodestr(node(">visual/shape",so())); Returns: fs3d\Operator.3DS Correct.
Just to check.
setnodenum(node(">visual/shapeindex",so()),7); Returns: 7 Correct.
Another way just to write in the node directly.

So it looks like that getshapeindex() is not working.
I have the same with gettextureindex(). Is not working.



@Iulian

To find the shape index of a shape you can use the following code.

Code:
 
// FIND SHAPE INDEX
// LOCAL VARIABLES
int index =1;
int OperatorShapeIndex;
treenode objectsnode = node("/project/media/objects",main());
// SEARCH THROUGH THE SHAPES
for(index=1; index<=content(objectsnode); index++)
{
// SEARCH FOR OPERATOR SHAPE
if(comparetext("fs3d\\Operator.3DS", getname(rank(objectsnode,index))))
{
// SET LOCAL VARIABLE
OperatorShapeIndex = getnodenum(rank(objectsnode,index));
}
}
// SREEN MESSAGE
msg("OperatorShapeIndex",concat("OperatorShapeIndex: ",numtostring(OperatorShapeIndex,0,0)));

I normally define a Global Variable for the shape index (e.g. OperatorShapeIndex) and use the above code to assign this variable at OnReset (e.g. User Event, Object Reset Trigger) and assign the shape of the object in the Object Reset Trigger.
In this way I am sure, that all my shapes are correct, for sure my own imported shapes for this specific model. As Cliff said, the index of the shapes might change with including more and other shapes. So if you use the above code you are safe.

If getshapeindex() would work, the code would be much easier:
getshapeindex("fs3d\\Operator.3ds");
So to assign the operator the shape would be just in the Object Reset:
setobjectshapeindex(current,getshapeindex("fs3d\\O perator.3ds"));

Anyway, I hope my explanation helps to understand and my code give you hints to make your own code.

Good success.
tom the (A)tom
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
  #4  
Old 11-23-2007
Iulian Marin Ion Iulian Marin Ion is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 14
Downloads: 53
Uploads: 0
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 155
Iulian Marin Ion is on a distinguished road
Default

Cliff / Tom,

Thank you very much to both of you.

The code posted by Tom is very good indeed for solving the version issue. I have also checked the script commands mentioned for getshapeindex and I get simmilar results - it seems to be a problem.

Regarding the following comments I am just putting them just as lauder thinking or maybe for someon else that could face with simmilar issues, in other topics even:
1. when "building my own itemflow" I have started from BasicBox (without paying attention from were I am starting, from a shape that does not have a file on his back)
2. I was further looking in Tools->Media Files to recognize the shape I was "generating" but that was not available (since NewItem in ItemFlow Bin does not generate a shape
3. Of course that I was not initialy understanding this, except when looking to the tree and understanding that some shapes have files on their back while others does not have, thinking to the implications of this and understanding that different treatment should be applied for "almost same categories" (which might be normal when thinking at the code optimisation)

Conclusion: not able to draw any except that code is at least 2 - 3 steps ahead to begginers thinking (which is not bad at all)

Iulian
  #5  
Old 11-23-2007
Cliff King's Avatar
Cliff King Cliff King is offline
Vice President Technical Services
 
Join Date: Jul 2007
Location: Utah
Posts: 272
Downloads: 158
Uploads: 14
Thanks: 102
Thanked 304 Times in 110 Posts
Rep Power: 412
Cliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud of
Default

Iulian,

I realize the documentation for what's available in the default FlowItem Bin is not sufficient. There is also very little documentation on the different attributes and what they mean. I can see how you would not know that the BasicBox was different than the other flowitems. I'm surprised you figured out that it didn't have an associated shape file, but instead used a special negative (-4) index which is a flag that tells Flexsim to draw a generic cube. Good job.

To try and help users understand what the flowitem attributes are and what they do, I put together this post Customizing Flowitem Attributes. I think it will help you understand the differences between the various default flowitems in the FlowItem Bin, and it will help you create your own flowitem to your own specifications.

Cliff
  #6  
Old 11-23-2007
Cliff King's Avatar
Cliff King Cliff King is offline
Vice President Technical Services
 
Join Date: Jul 2007
Location: Utah
Posts: 272
Downloads: 158
Uploads: 14
Thanks: 102
Thanked 304 Times in 110 Posts
Rep Power: 412
Cliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud ofCliff King has much to be proud of
Default

Tom,

The getshapeindex() command does exactly the same thing as your code. It does a text comparison. Which means that it is case sensitive - even for the file extensions. In other words, Operator.3ds is not the same as Operator.3DS

Cliff
  #7  
Old 11-24-2007
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 520
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default

Cliff,

This is why you are the King and I am only little tom.

You are right and tried to figure out what confused me during my testing.

If you copy the Path from the Media Files GUI ‘Preloaded Shapes and Images’ it is not working, because you need a second ‘\’ in the path.
That’s the copied path.
getshapeindex("fs3d\Operator.3DS"); Failure!.

Here the correct command:
getshapeindex("fs3d\\Operator.3DS"); Works correct.

So I recommend for everybody to keep in mind, that the strings are case sensitive and that in the path you need two backslashes ‘\\’ because the backslash is a special char in C++.


@ Iulian
This code is working:
setobjectshapeindex(current,getshapeindex("fs3d\\O perator.3DS"));

So this is a shorter and easier way than my above code.

It’s always nice to learn something.
tom the (A)tom
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
  #8  
Old 05-08-2013
KvThiel KvThiel is offline
Flexsim User
 
Join Date: Jan 2013
Posts: 12
Downloads: 3
Uploads: 0
Thanks: 2
Thanked 0 Times in 0 Posts
Rep Power: 89
KvThiel is on a distinguished road
Default Cannot change the object image index in the same way as the shape

I tried to change instead of the shape, the image. But this is not working in the same way.
How can I make it possible

I have a visualtool(plane) with a dynamic traffic sign (green arrow). after a process the dynamic traffic sign has to change from the green arrow into a red cross.

I pre-loaded the images (see attachements) into the media files.
7 - green arrow
8 - red cross

at the on ExitTrigger I coded:
setobjectimageindex(current,8);

But it does not work, how can it be fixed?

Kind regards,

Koen van Thiel
Attached Images
File Type: jpg matrixbord_nw_pijl.jpg (39.8 KB, 94 views)
File Type: jpg matrixbord_nw_kruis.jpg (43.1 KB, 99 views)
  #9  
Old 05-08-2013
Jörg Vogel's Avatar
Jörg Vogel Jörg Vogel is offline
Flexsim User
 
Join Date: Sep 2007
Location: Hannover, Germany
Posts: 643
Downloads: 35
Uploads: 0
Thanks: 802
Thanked 665 Times in 410 Posts
Rep Power: 642
Jörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond repute
Default

try the command
Code:
setobjecttextureindex(obj object, num index)
import the images as images not shapes in the media files.
The Following User Says Thank You to Jörg Vogel For This Useful Post:
KvThiel (05-13-2013)
  #10  
Old 08-05-2013
David Chan David Chan is offline
Flexsim Distributor
 
Join Date: Sep 2007
Posts: 326
Downloads: 74
Uploads: 0
Thanks: 217
Thanked 73 Times in 44 Posts
Rep Power: 218
David Chan has a spectacular aura aboutDavid Chan has a spectacular aura aboutDavid Chan has a spectacular aura about
Default Media Files Issues

Hi

I have tried to pre-load the media using Media Files function. I have added three shape files. However when I open model in another computer I saw only two files are in the media files.

I have another question. Since the Media files is to pre-load the media files. When I send the model to someone, do I still need to send the image files? Or just the model alone is sufficient.

I am using v6.02.

Thanks

David
__________________
Advent2 Labs
David



All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.