ATTENTIONThis 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 |
|
Downloads |
Q&A Using Flexsim and building models |
#1
|
|||
|
|||
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 |
#3
|
|||
|
|||
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 |
#4
|
||||
|
||||
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. |
#5
|
|||
|
|||
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(); Code:
for(int xx = 1; xx <= nrop(current); xx++) { treenode newlabel = addlabel(current,getnodename(outobject(current,xx))); } Code:
nodoactual = current; siguientenodo = getnodefromrank(getnextnetnode(rankfromnetnode(current),rankfromnetnode(destino))); setlabelnum(nodoactual,getname(netnodefromrank(rankfromnetnode(siguientenodo))),tonum(traveler)); 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 |
#6
|
||||
|
||||
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. |
The Following User Says Thank You to Phil BoBo For This Useful Post: | ||
Pablo Concha (09-05-2014) |
#7
|
|||
|
|||
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. i'm going to try and replicate this on a smaller model... thanks for your input Phil regards Pablo Quote:
Quote:
|
#8
|
||||
|
||||
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. |
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 |