AnswerHub Upload Issue
Our AnswerHub community currently has a bug that prevents you from attaching your model or other files to your questions. AnswerHub is aware of this issue and they are working on a fix. Until we receive their patch, you can upload your models and other files to FlexSim's file share site. Include the file name in your question so that we know which upload to reference.

question

Miguel_ngel Ra avatar image
0 Likes"
Miguel_ngel Ra asked Jason Lightfoot commented

Create automatically points and network in GIS


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.

bodegas_sample.xlsx

FlexSim 22.1.0
flexscriptlogisticsgisagv routing
bodegas-sample.xlsx (14.4 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

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.

0 Likes 0 ·
Phil BoBo avatar image
1 Like"
Phil BoBo answered Phil BoBo edited
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

i need something that create automatically points and distance between them, not doing 1 per 1.
0 Likes 0 ·

Put the code you need from the example into a loop using your own code that accesses your data and uses it the way you want.

0 Likes 0 ·
Alyson P avatar image
0 Likes"
Alyson P answered Miguel_ngel Ra commented

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.

· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Thanks Alyson


How do you insert the script? inside of some structure of processflow?

0 Likes 0 ·
Alyson P avatar image Alyson P Miguel_ngel Ra ·
I created a GUI, because I nedd a user friendly interface, and inserted the code in the buttons.
0 Likes 0 ·
would you share with me your flexsim file to see how create a GUI please
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.