question

Chris Smith avatar image
2 Likes"
Chris Smith asked Ben Wilson edited

How can AStar Barriers be created in FlexScript?

I am trying to create a model that uses the AStar module from an excel file. I have some basic characteristics that would define the barriers in the model (location and size). Could someone help me understand the preferred method for creating AStar barriers in FlexScript? The way I am currently thinking about doing it is saving off a created Barrier as a node and then creating a copy of that and editing the x, y coordinates of the points. I just wanted to make sure there aren't any more preferred methods or commands to accomplish this.

Choose One
astarbarrier
5 |100000

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

1 Answer

Matt Long avatar image
6 Likes"
Matt Long answered Ben Wilson edited

The A* Navigator has functions on it that create barriers, dividers etc. For example, if you wanted to create a solid barrier that started at 0, 0 and ended at 10, 10 you would call:

  1. function_s(node("AStarNavigator", model()), "addBarrier", 0, 0, 10, 10, EDITMODE_SOLID_BARRIER);

The dividers and preferred paths are a little more complicated, but here's an example of adding a divider with 3 legs:

  1. treenode aStar = node("AStarNavigator", model());
  2. treenode barrier = function_s(aStar, "addBarrier", 0, 0, 10, 10, EDITMODE_DIVIDER); //1st leg
  3. function_s(aStar, "setBarrierMode", barrier, 3); //Editing barrier
  4. function_s(aStar, "onClick", activedocumentnode(), LEFT_RELEASE, 10, 20); //2nd leg
  5. function_s(aStar, "onClick", activedocumentnode(), LEFT_RELEASE, 20, 20); //3rd leg
  6. function_s(aStar, "setBarrierMode", barrier, 0); //Done editing

The other edit modes are EDITMODE_ONE_WAY_DIVIDER and EDITMODE_PREFERRED_PATH.

Once you reset the model, all of the created barriers will be added to the network.

If you need to add objects as barriers or to the network, just use:

  1. contextdragconnection(node("Operator1", model()), node("AStarNavigator", model()), "A");

Hope that helps.

· 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.