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 05-07-2013
Ramesh Pinn Ramesh Pinn is offline
Flexsim User
 
Join Date: Oct 2012
Location: Tampa, FL
Posts: 16
Downloads: 0
Uploads: 0
Thanks: 12
Thanked 2 Times in 2 Posts
Rep Power: 93
Ramesh Pinn is on a distinguished road
Default 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())));
adding a new bay or modifying exiting one (this is called inside a loop):
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++;
adding a new level or modifying existing one (this is called inside a loop):
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++;
Once the above loops are complete, I would like to repaint the object. repaintall() or repaintview(rack) does not seem to work.

Thanks in advance.
  #2  
Old 05-07-2013
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: 1174
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

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  
Old 05-07-2013
Ramesh Pinn Ramesh Pinn is offline
Flexsim User
 
Join Date: Oct 2012
Location: Tampa, FL
Posts: 16
Downloads: 0
Uploads: 0
Thanks: 12
Thanked 2 Times in 2 Posts
Rep Power: 93
Ramesh Pinn is on a distinguished road
Default

Quote:
Originally Posted by Phil BoBo View Post
function_s(node("/Rack", library()), "RefreshTable", rack);
repaintall();
Thanks for the reply Phil. I tried that but I am unable to call function_s from the DLL since the function definition in the DLL is as follows:

Code:
inline double function_s(treenode node, char * name, n30argsdefaultinterface){return function_s_alias(node, name, n30args);}
This translates into function_s(treenode node, char* name, double n1, double n2 ...). This will throw an error at compile time.Is there a workaround? or another function?
  #4  
Old 05-07-2013
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: 1174
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

Quote:
Originally Posted by Ramesh Pinn View Post
This will throw an error at compile time.
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  
Old 05-07-2013
Ramesh Pinn Ramesh Pinn is offline
Flexsim User
 
Join Date: Oct 2012
Location: Tampa, FL
Posts: 16
Downloads: 0
Uploads: 0
Thanks: 12
Thanked 2 Times in 2 Posts
Rep Power: 93
Ramesh Pinn is on a distinguished road
Default

Quote:
Originally Posted by Phil BoBo View Post
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));
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  
Old 05-07-2013
Cameron Pluim Cameron Pluim is offline
Steelcase, Inc.
 
Join Date: Apr 2012
Location: MI
Posts: 30
Downloads: 27
Uploads: 11
Thanks: 5
Thanked 34 Times in 20 Posts
Rep Power: 120
Cameron Pluim will become famous soon enoughCameron Pluim will become famous soon enough
Default

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  
Old 05-08-2013
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

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  
Old 05-08-2013
Ramesh Pinn Ramesh Pinn is offline
Flexsim User
 
Join Date: Oct 2012
Location: Tampa, FL
Posts: 16
Downloads: 0
Uploads: 0
Thanks: 12
Thanked 2 Times in 2 Posts
Rep Power: 93
Ramesh Pinn is on a distinguished road
Thumbs up

Quote:
Originally Posted by Cameron Pluim View Post
Try adding DECLARE_FLEXSIM_FUNCTION(tonum) to your FlexsimFuncs.h
This worked.

Its typedef was already available in FlexsimFuncs.h,
Code:
typedef double (*_tonum)(treenode x);
However, the declaration was not there for some reason. Adding it fixed the issue. Thanks!

I am able to call the function_s as suggested by Phil and it paints the rack correctly in the 3D View.
  #9  
Old 05-08-2013
Ramesh Pinn Ramesh Pinn is offline
Flexsim User
 
Join Date: Oct 2012
Location: Tampa, FL
Posts: 16
Downloads: 0
Uploads: 0
Thanks: 12
Thanked 2 Times in 2 Posts
Rep Power: 93
Ramesh Pinn is on a distinguished road
Default

Quote:
Originally Posted by Steven Hamoen View Post
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()
I tried this and it worked as well. Thank you.

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"));
Attached Images
File Type: jpg nodefunction.jpg (13.9 KB, 81 views)
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


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.