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
FAQ Downloads Calendar Search Mark Forums Read

Q&A Using Flexsim and building models

Reply
 
Thread Tools Display Modes
  #1  
Old 09-05-2014
Pablo Concha Pablo Concha is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 104
Downloads: 100
Uploads: 1
Thanks: 103
Thanked 52 Times in 37 Posts
Rep Power: 228
Pablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nice
Default problem creating model through custom gui and user library

Hi,

we have a couple of modified objects on a user library which we use to create a model through a custom GUI (create copy of objects and connect them). If we save the model created, close flexsim, open flexsim and load the model, we have no problem when running it. But if we run it just after creating it without closing flexsim we┬┤re getting an error regarding a pointer to a network node that is not updated sometimes (asigned using the command netnodefromrank(getnextnetnode())) ...

is there something we should do after creating/copying the objects through commands before running the model, such as the optimizenetwork() when creating a path network?...is there something flexsim does or executes when openening a model that makes the model not to give that error?...

i cant upload the model at the moment.. sorry... just ask if you need more information... any idea/help is welcome...

regards

Pablo
Reply With Quote
  #2  
Old 09-05-2014
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1170
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

Are you resetting the model after creating objects?
Reply With Quote
  #3  
Old 09-05-2014
Pablo Concha Pablo Concha is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 104
Downloads: 100
Uploads: 1
Thanks: 103
Thanked 52 Times in 37 Posts
Rep Power: 228
Pablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nice
Default

yes.. reseting it before run it...
what i think is weird is that just after creating it it shows an error, but if i save it, close flexsim, open the model again, it shows no problem...

regards

Pablo
Reply With Quote
  #4  
Old 09-05-2014
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1170
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

You would get better help if you posted more specifics about what you are doing, what you are seeing, and what you expected to see.

For example, you could post the code that you use to "create copy of objects and connect them", and you could show exactly what the error is "regarding a pointer to a network node that is not updated sometimes".

If you can't post the model, at least post enough information so that we can get an idea of what you are seeing.

Or send the model to FlexSim Support for specific help.
Reply With Quote
  #5  
Old 09-05-2014
Pablo Concha Pablo Concha is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 104
Downloads: 100
Uploads: 1
Thanks: 103
Thanked 52 Times in 37 Posts
Rep Power: 228
Pablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nice
Default

Hi,

I'm using this to create a copy of a node into the model on a position given by a global table called "nodos" which gives the position of the node on x,y and z and then conect the nodes according to the table "conexiones" wich tellsme which node is conected to one another:

Code:
treenode nnobj = node("/project/userlibrary/UserLibrary 1/NN2", main()); //puntero a nodos de la libreria
treenode nuevonodo; //puntero para uso en el ciclo
treenode desde;     //puntero para uso en conexiones
treenode hasta;		//puntero para uso en conexiones


for(int xx = 1; xx <= gettablerows("nodos"); xx++)		// Ciclo para generar los nodos en base a tabla "nodos"
{
	nuevonodo = createinstance(nnobj,model());
	setname(nuevonodo,gettablestr("nodos",xx,1));
	setloc(nuevonodo,gettablenum("nodos",xx,2),gettablenum("nodos",xx,3),gettablenum("nodos",xx,4));
}

for(int yy = 1; yy <= gettablerows("conexiones"); yy++)	// Ciclo para conectar nodos creados en base a tabla "conexiones"
{
	desde = node(concat("/",gettablestr("nodos",gettablenum("conexiones",yy,1),1)),model());
	
	hasta = node(concat("/",gettablestr("nodos",gettablenum("conexiones",yy,2),1)),model());
	
	contextdragconnection(desde,hasta,"A");
		
}
optimizenetwork();
conexiones = 0;

repaintall();
the network is created with no problem, then on reset this code on the reset trigger of the nodees creates as many labels on each node as conections to other nodes exists.

Code:
for(int xx = 1; xx <= nrop(current); xx++)
{
	treenode newlabel = addlabel(current,getnodename(outobject(current,xx)));
	
}
I use this labels to control vehicles and the distance and interaction rules between them saving a pointer to the vehicle x nodes ahead of the node where the vehicle is and x nodes behind in the way it's moving, for these i use the lines:

Code:
nodoactual = current;
siguientenodo = getnodefromrank(getnextnetnode(rankfromnetnode(current),rankfromnetnode(destino)));
setlabelnum(nodoactual,getname(netnodefromrank(rankfromnetnode(siguientenodo))),tonum(traveler));
among other things

all this works ok after i create the network on most nodes,but on some (this is random) y might get an error. If i save the model, open and run it again i tget no error.. this is the thing that puzzled me.. if it's the code that's broken, it should be broken every time, not only after i create the network and then if i save the model it fixes itself...

i'm sorry if this information is not enough, i'm asking permission to send the model to support... also i'm not sure if i make myself clear what the problem is, my english is not good enough apparently...

regards

Pablo
Reply With Quote
  #6  
Old 09-05-2014
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1170
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

First, you shouldn't call createinstance() on an object in a userlibrary. That command is used to create instances of library class objects. Objects in a user library are already instances of library class objects. You should use createcopy() to create a user library object in your model.

Second, you still haven't posted what the error you are getting is. Is it a message box? Is it a print in the system console? What exactly does the error say? When does it happen? When you are running the model? When you reset the model? When you run the script that generates the objects? When you connect the objects?

Third, is getnodefromrank() a user command in your model? That isn't a FlexSim command. Is that a typo? Should it be netnodefromrank()?

Fourth, getname(netnodefromrank(rankfromnetnode(siguienten odo)))? That isn't doing anything more than getname(siguientenodo). Why are you calling netnodefromrank() and rankfromnetnode() there?

Try to duplicate the problem in a simple sample model instead of in your real model. By doing that, you will probably figure out what your problem is. And even if you don't figure it out yourself, you will then have a simple sample model that you can upload without needing to get permission so that we can duplicate your problem and figure out what is wrong.

Last edited by Phil BoBo; 09-05-2014 at 04:15 PM.
Reply With Quote
The Following User Says Thank You to Phil BoBo For This Useful Post:
Pablo Concha (09-05-2014)
  #7  
Old 09-05-2014
Pablo Concha Pablo Concha is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 104
Downloads: 100
Uploads: 1
Thanks: 103
Thanked 52 Times in 37 Posts
Rep Power: 228
Pablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nice
Default

The error i get is:

Code:
time: 1940.878941 exception: Exception Caught in rankfromnetnode(treenode netnode)
time: 1940.878941 exception: Exception Caught in ObjectFunction175__project_exec_commandlist_rankfromnetnode_node object: MAIN:/project/exec/commandlist/rankfromnetnode/node class: MAIN:/project/exec/commandlist/rankfromnetnode/node

time: 1940.878941 exception: Exception Caught in getnextnetnode(int fromnn, int tonn)
time: 1940.878941 exception: Exception Caught in ObjectFunction108__project_exec_commandlist_getnextnetnode_node object: MAIN:/project/exec/commandlist/getnextnetnode/node class: MAIN:/project/exec/commandlist/getnextnetnode/node

time: 1940.878941 exception: Exception Caught in rankfromnetnode(treenode netnode)
time: 1940.878941 exception: Exception Caught in ObjectFunction175__project_exec_commandlist_rankfromnetnode_node object: MAIN:/project/exec/commandlist/rankfromnetnode/node class: MAIN:/project/exec/commandlist/rankfromnetnode/node

time: 1940.878941 exception: Exception Caught in getnextnetnode(int fromnn, int tonn)
time: 1940.878941 exception: Exception Caught in ObjectFunction108__project_exec_commandlist_getnextnetnode_node object: MAIN:/project/exec/commandlist/getnextnetnode/node class: MAIN:/project/exec/commandlist/getnextnetnode/node

time: 1940.878941 exception: Exception caught in flexscript execution of MODEL:/NN47>variables/arrivaltrigger line 961 instruction 2996. Discontinuing execution.
time: 1940.878941 exception: Exception caught in flexscript execution of MODEL:/NN47>variables/arrivaltrigger line 961 instruction 2996 (evaluating command parameter 1 as number). Discontinuing execution.
time: 1940.878941 exception: Exception caught in flexscript execution of MODEL:/NN47>variables/arrivaltrigger line 961 instruction 2996. Discontinuing execution.
time: 1940.878941 exception: Exception caught in flexscript execution of MODEL:/NN47>variables/arrivaltrigger line 961 instruction 2996 (evaluating command parameter 1 as number). Discontinuing execution.
time: 1940.878941 exception: Exception caught in flexscript execution of MODEL:/NN47>variables/arrivaltrigger line 961 instruction 2996. Discontinuing execution.
time: 1940.878941 exception: Exception caught in flexscript execution of MODEL:/NN47>variables/arrivaltrigger line 961 instruction 2996. Discontinuing execution.
on the system console. This happens when i run the model on a random node (all nodes have the same code) at different times. like i said, if i save the model and open it again i don't get this error.

i'm going to try and replicate this on a smaller model... thanks for your input Phil

regards

Pablo

Quote:
Third, is getnodefromrank() a user command in your model? That isn't a FlexSim command. Is that a typo? Should it be netnodefromrank()?
yup typo

Quote:
Fourth, getname(netnodefromrank(rankfromnetnode(siguienten odo)))? That isn't doing anything more than getname(siguientenodo). Why are you calling netnodefromrank() and rankfromnetnode() there?
yup.. you're right... didn't see that one...
Reply With Quote
  #8  
Old 09-05-2014
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1170
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

Now that you've posted the error, I can see where the problem is happening:

Debug line 961 on your NN47's arrivaltrigger. On that line, you are calling rankfromnetnode() and passing in a treenode as a parameter. The treenode you are passing is either (1) NULL, (2) not a network node, or (3) not connected to a navigator. Debug the code to see what is being passed in.

If the problem is #1 or #2, figure out where you got the reference and make sure it is a valid network node.

If the problem is #3, check the node's variables to make sure it is correctly connected to the DefaultNetworkNavigator. For example, if you are passing NN47, check that NN47>variables/network/1 is a valid coupling to your DefaultNetworkNavigator>variables/nodemembers/#. Also, check to make sure that NN47>variables/network/1 has a subnode that has number data equal to the rank of the other coupling in the NetworkNavigator's nodemembers.

If the problem is #3 and something looks incorrect with those nodes, then you need to figure out what is happening to cause it be messed up. These nodes should all get correctly created and set when you reset the model. If that isn't happening, then you'll probably need to send the model to Support to figure out why.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a custom GUI for creating an item ? mearjun Q&A 5 05-30-2013 05:41 PM
Pulling Object User Library shashanktrivedi Q&A 1 06-09-2011 10:16 AM
How to save several objects as one object and put it into custom library Chunyan Liang Q&A 1 10-15-2010 03:25 AM
How to add objects to user library in V 5 Sebastian Hemmann Q&A 4 10-06-2010 04:43 AM
problem with automatic generation of objects by using a user library and c++ Martin Saler Q&A 17 06-05-2009 09:56 AM


All times are GMT -6. The time now is 10:27 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.