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 01-26-2012
ericdaoust ericdaoust is offline
Flexsim User
 
Join Date: Nov 2011
Location: Sudbury, Ontario, Canada
Posts: 13
Downloads: 6
Uploads: 0
Thanks: 5
Thanked 1 Time in 1 Post
Rep Power: 103
ericdaoust is on a distinguished road
Default 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.
Attached Files
File Type: fsm spline_example.fsm (26.8 KB, 117 views)
  #2  
Old 01-26-2012
Sebastian Hemmann's Avatar
Sebastian Hemmann Sebastian Hemmann is offline
Flexsim User
 
Join Date: Sep 2009
Location: Braunschweig (Germany)
Posts: 439
Downloads: 52
Uploads: 0
Thanks: 472
Thanked 217 Times in 154 Posts
Rep Power: 319
Sebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to behold
Default

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  
Old 01-26-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

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  
Old 01-31-2012
ericdaoust ericdaoust is offline
Flexsim User
 
Join Date: Nov 2011
Location: Sudbury, Ontario, Canada
Posts: 13
Downloads: 6
Uploads: 0
Thanks: 5
Thanked 1 Time in 1 Post
Rep Power: 103
ericdaoust is on a distinguished road
Default

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);
The x/y/z values should be changed according to your needs.

Note: "from" should be the node in which the spline object data resides (the node of origin when doing the "A" connection).
  #5  
Old 10-21-2013
Pablo Concha Pablo Concha is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 104
Downloads: 100
Uploads: 1
Thanks: 103
Thanked 52 Times in 37 Posts
Rep Power: 232
Pablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nicePablo Concha is just really nice
Default

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  
Old 10-21-2013
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

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


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.