I want to add a dynamic barrier using the custom code object in the process flow. How do I call and use this command?
I want to add a dynamic barrier using the custom code object in the process flow. How do I call and use this command?
Hi @JP117, was Jason Lightfoot's answer helpful? If so, please click the "Accept" button at the bottom of their answer. 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 comment back to reopen your question.
Have you checked the example Kiva model?
You're right - that's using a per Route Calculation method to return a list of barriers. You can just use something like:
Variant barrier=AStar.navigator.addDynamicBarrier(Vec3(0,0,0),Vec3(1,1,1),Vec3(0,0,0),0);
...where you record the barrier treenode reference(s) in order to remove it (them) later
AStar.navigator.removeDynamicBarrier(barrier)
I am getting this error? What am I missing. This is the first time using custom code
You're not using the Vec3 constructor before your coordinate parentheses.
got it thanks. If I was creating multiple barriers could I name them like var barrierA and var barrierB. That way I could call the barrier I want to remove?
By the way you could also use brackets for your coordinates and it will convert automatically to Vec3 - so [1,1,1] would also work.
For that I would create a map. I'm conscious that this your first custom code, but I'd like to set you off with a good method.
The 'barrier' is the thing we need to store for future use - renaming it won't help us much.
Now, you can add a barrier for objects as well as 'abstract' cuboid dimensions as we did in the example above. So when you want to find the barrier that was created, it could be that we have an object as the reference or in the case of the abstract cuboid a name like: "CongestionAreaCuboid1".
A map is like an array but instead of using the numeric position in the array to find the stored value, we use a key which can be almost anything - including objects and strings. To store the barrier in a map with a string key you would use someting like:
Map myBarrierMap; myBarrierMap["CongestionAreaCuboid1"]=barrier;// where barrier was returned by addDynamicBarrier();
then to store it on a token:
token.myBarrierMap=myBarrierMap.clone(); //clone may not be necessary
When you want to access it just use:
var barrier=token.myBarrierMap.as(Map)["CongestionAreaCuboid1"]; AStar.navigator.removeDynamicBarrier(barrier);
The map also works for objects:
var barrier=AStar.navigator.addDynamicBarrier(myObject); myBarrierMap[myObject]=barrier;
and to retrieve:
var barrier=token.myBarrierMap.as(Map)[myObject];
Lastly you might also consider that you can pass an array into addDynamicBarrier (eg. a collection of objects) which will then return an array of barriers. In this case you may want to create a key/barrier value for each of the array entries.
16 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