I have data of many stores across Lima and I need to set them in the map automatically using Flexscript and create the network between them to start to experiment alternatives to delivering products to the stores.
I have data of many stores across Lima and I need to set them in the map automatically using Flexscript and create the network between them to start to experiment alternatives to delivering products to the stores.
Hi @Miguel_ngel Ra, was one of Phil BoBo's or Alyson P's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.
If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.
Hello @Miguel_ngel Ra sure, I'll send you the code and explain what I have done in it.
//create a navigator object Object navigator = model().find("GISNavigator"); //clear all the previous points in the map navigator.subnodes.clear(); //reference an existing global table with all the cities and their latitude and longitude Table table = reftable("GlobalTable1"); //a for to search all the rows in the global table for(int i = 1; i <= table.numRows; i++){ //create a point in the navigator Object point1 = createinstance(library().find("/GIS/Point"), navigator); //set the properties of the points using values from global table point1.name = table[i][1]; point1.setProperty("Latitude", table[i][2]); point1.setProperty("Longitude", table[i][3]); //set the size of the points and their color, nothing really important point1.setSize(40, 30, 20); point1.color = Color.red; //store all the points in a vector in case I need them, not really important too vetor_pontos[i] = point1; //repaint the map to show new points repaintall();
In my model I did not connect all the dots when creating them, I am using clusters so when creating teh cluster, I also create the connection
contextdragconnection(point1, point2, "A");
And after the connection is done, you can use the following code to get their distances
double distance = function_s(point1, "getDistance", point2);
It is also worth mention that to fill my global table I created a function that gets all the data from an Excel spreadsheet and only them I referenced it as showed in the first piece of code.
If you have any other question that I can help, feel free to send me another message and sorry for taking a lilttle long to answer you.
Thanks Alyson
How do you insert the script? inside of some structure of processflow?
I am modeling something like this. thank you for your great guideline. as for the "getDistance", it is a built-in function for GIS point, right? if yes, but I cannot find it's treeNode. it will be better if you can give some explanation on this. thank you very much!
It's a function of the class that doesn't appear under instances in the model tree.
thanks for your answer. additionally, I also can't find the function "getDistance" from user manual.
18 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved