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
|
||||
|
||||
Get view reference
Maybe this is a simple question. Is there an easy way to get the treenode reference of view that is just created by using createview() command? The createview() returns a NULL.
This could be useful if we want to manipulate the created view using code, for example, setting the locations of the view. Thanks.
__________________
Best, Alan |
#2
|
||||
|
||||
You can get a reference to the last node in VIEW:/active after you've created the view to get a handle on it. There may be better ways to do this, but this way works.
createview("VIEW:/standardviews/modeltree",0,0); treenode newview = last(node("/1",views())); set(spatialx(newview),50); set(spatialy(newview),50); set(spatialsx(newview),300); set(spatialsy(newview),300); refreshview(newview); |
#3
|
||||
|
||||
This is another way to actually change the view's data before you open it. This could lead to problems though if you change a standard view: everywhere that Flexsim opens that view will use the values you set until you close Flexsim and reopen it.
string viewpath = "VIEW:/standardviews/modeltree"; treenode viewnode = node(viewpath); set(spatialx(viewnode),50); set(spatialy(viewnode),50); set(spatialsx(viewnode),300); set(spatialsy(viewnode),300); createview(viewpath,0,0); |