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 |
#1
|
|||
|
|||
Rack Dimensions from DLL
I am trying to create instances of a rack from a DLL. It works to the point where the data is correctly set and I can verify this in the object tree. However, the visual display of the rack still shows the default rack you would find in the library (10 bays with 10 levels each). The visual image of the rack is correctly displayed when I open the properties of the rack and click on any column in the list of bays in the SizeTable screen.
Is there a way to repaint the object by making a specific function call in the code after I am done adding all the bays and levels? The following are relevant snippets of code I am using: Creating the rack and setting the sizetable to 1 bay with 1 level: Code:
//for each rowID, create a new rack treenode rack = createinstance(node("MAIN:/project/userlibrary/CustomLib/CustomRack"),model()); //setlabelnum(rack,"setSize",1); treenode sizetable = getvarnode(rack, "sizetable"); clearcontents(sizetable); nodeinsertinto(sizetable); treenode tempbay = last(sizetable); setname(tempbay,concat("Bay",numtostring(1,0,0))); nodeadddata(tempbay,DATATYPE_NUMBER); setnodenum(tempbay,3); nodeinsertinto(tempbay); treenode templevel = last(tempbay); setname(templevel,concat("Level",numtostring(1,0,0))); nodeadddata(templevel,DATATYPE_NUMBER); setnodenum(templevel,3); setname(rack, concat("R", numtostring(itRowGroupList->getId()))); Code:
//get existing bay or create new treenode bay = first(sizetable); if(bayCount > 0) { bay = createcopy(last(sizetable), sizetable); } clearcontents(bay); nodeinsertinto(bay); templevel = last(bay); setname(templevel,concat("Level",numtostring(1,0,0))); nodeadddata(templevel,DATATYPE_NUMBER); setnodenum(templevel,3); setname(bay, concat("Bay", numtostring(itRowBays->getId()))); bayCount++; Code:
//get existing level or create new treenode level = first(bay); if(levelCount > 0) { level = createcopy(last(bay), bay); } setname(level, concat("Level", numtostring(itBayLevels->getId()))); levelCount++; Thanks in advance. |
#2
|
||||
|
||||
function_s(node("/Rack", library()), "RefreshTable", rack);
repaintall(); |
The Following 2 Users Say Thank You to Phil BoBo For This Useful Post: | ||
Ramesh Pinn (05-07-2013) |
#3
|
|||
|
|||
Quote:
Code:
inline double function_s(treenode node, char * name, n30argsdefaultinterface){return function_s_alias(node, name, n30args);} |
#4
|
||||
|
||||
What error at compile time are you getting?
If it is that you can't convert a treenode to a double, then use the tonum() command: function_s(node("/Rack", library()), "RefreshTable", tonum(rack)); |
The Following User Says Thank You to Phil BoBo For This Useful Post: | ||
Jörg Vogel (05-08-2013) |
#5
|
|||
|
|||
It is the treenode to double error. However, if I try use tonum, it says function undefined. Maybe this function is not declared in DLLMaker?
|
#6
|
|||
|
|||
Try adding DECLARE_FLEXSIM_FUNCTION(tonum) to your FlexsimFuncs.h
|
The Following User Says Thank You to Cameron Pluim For This Useful Post: | ||
Ramesh Pinn (05-08-2013) |
#7
|
||||
|
||||
Easy way out is simply calling function_s on a flexscript toggled node in Flexsim and then call that node from the DLL with nodefunction()
|
The Following 2 Users Say Thank You to Steven Hamoen For This Useful Post: | ||
Ramesh Pinn (05-08-2013) |
#8
|
|||
|
|||
Quote:
Its typedef was already available in FlexsimFuncs.h, Code:
typedef double (*_tonum)(treenode x); I am able to call the function_s as suggested by Phil and it paints the rack correctly in the 3D View. |
#9
|
|||
|
|||
Quote:
I added the following node under labels node of the CustomRack object in my userlibrary as shown in the attachment below. and called the following code in the DLL: Code:
nodefunction(label(rack,"repaintObj")); |
The Following User Says Thank You to Ramesh Pinn For This Useful Post: | ||
Steven Hamoen (05-08-2013) |
Thread | Thread Starter | Forum | Replies | Last Post |
Setting the Dimensions of a rack | Nico Zahn | Q&A | 5 | 08-10-2010 01:28 PM |