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
|
|||
|
|||
Flexscript question (network nodes and splines)
I attached a very basic model with two network nodes and a path linking them. I know how to curve this path manually but I want to do this in Flexscript to do it dynamically in a larger project.
Does anyone know a series of commands that will accomplish what I want? Thanks in advance. |
#2
|
||||
|
||||
I don´t got any idea if there exists such commands. But if you don´t find any other solution you could have a look into tree and see what hapens while you set your options manualy. Then you only have to work with standard tree settings and commands.
__________________
Hemmi |
#3
|
|||
|
|||
Here's some code for creating a single spline point, which might be easier to manage than two. The coordinates are relative to the network node that contains the spline end points that were created when you connected the two nodes, and is the node you dragged from.
Code:
treenode networknode=node("/NN1",model()); // This is the network node you did a drag connect FROM treenode splineend1 =first(networknode); double x=1; double y=1; double z=0; if(nrop(outobject(splineend1, 1)) == 0) { treenode splineend2=outobject(splineend1, 1); clearcontents(connectionsout(splineend1)); treenode splinepoint=createinstance(node("/SplinePoint",library), up(splineend1)); setloc(splinepoint,x,y,z); objectconnect(splineend1, splinepoint); objectconnect(splinepoint, splineend2); } set(node("/DefaultNetworkNavigator>variables/modified",model()), 1); |
The Following 8 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
syseo (01-31-2012) |
#4
|
|||
|
|||
To expand on this solution, I've created a user function that does this for any two network nodes.
modifyspline(treenode from, int fromPort) Code:
treenode net1=parnode(1); int net1Port = parval(2); treenode splineend1 =node(concat("/", numtostring(net1Port)), net1); double x = 1; double y = 1; double z = 0; treenode splineend2=outobject(splineend1, 1); clearcontents(connectionsout(splineend1)); treenode splinepoint=createinstance(node("/SplinePoint",library), up(splineend1)); setloc(splinepoint,x,y,z); objectconnect(splineend1, splinepoint); objectconnect(splinepoint, splineend2); set(node("/DefaultNetworkNavigator>variables/modified",model()), 1); Note: "from" should be the node in which the spline object data resides (the node of origin when doing the "A" connection). |
#5
|
|||
|
|||
Hi,
i'm using the examples of this post to generate splines to caracterize curves when generating paths... but now it's not working on version 7. i get the error: exception: Exception caught in flexscript execution of line 6 instruction 18. Discontinuing execution. not sure how to fx this... any help is welcome... regards Pablo |
#6
|
|||
|
|||
In version 7 the splines have moved to the connectionsout node inside the network node, so the previous code won't work. Try this:
treenode nn=so(); int edgeno=1; treenode edge=rank(connectionsout(nn),edgeno); function_s(nn,"setEdgeGeomType",edge,0); treenode splines=node("/spline",rank(connectionsout(nn),edgeno)); treenode spline1=rank(splines,2); treenode spline2=rank(splines,3); setloc(spline1,x1,y1,z1); setloc(spline2,x2,y2,z2); |
The Following 4 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
Phil BoBo (10-21-2013) |
Thread | Thread Starter | Forum | Replies | Last Post |
draw network nodes using data from an excel sheet | Vinay Mehendiratta | Q&A | 7 | 10-14-2014 08:40 AM |
Remove the arrows and green dots from the link joining 2 network nodes | Nischith Kashyap | Q&A | 3 | 09-19-2011 09:27 AM |
Network Nodes | Rachid Kolfin | Q&A | 14 | 02-03-2011 08:34 PM |
cubic splines | Alex Christensen | User Development | 2 | 12-18-2008 04:54 PM |
Connecting network nodes in different containers | KelvinHo | Q&A | 1 | 05-28-2008 06:49 AM |