You need to pass the GET_PROPERTY_FLAG_UNITS flag into the Object.getProperty() method.
If you pass that flag it will return a 2-length array with the display value in the first element and the display units in the second. Without that flag it will return the value in model units.
For example, say you set the Process Time of Processor1 to be 10 minutes in a model with seconds as the model time unit. Then the getProperty method will return:
Object obj = Model.find("Processor1"); obj.getProperty("ProcessTime", GET_PROPERTY_FLAG_UNITS); // [10, min] obj.getProperty("ProcessTime"); // 600
Do you know how to get the "Unit" of a Source Object's "InterArrivalTime" property? I use the code below for "Processor" it works fine but for this property of a "Source" object, it does not work..
getProperty() only returns the units if the value is a number. That property probably has code for its value instead of a straight number and so it's just returning the string of code. If you have a different unit defined for that code though it will be written into the code.
You could parse that text though and find the model unit, something like this:
Object obj = Model.find("Source1"); string units = obj.getProperty("InterArrivalTime").match(/unitConversion:[a-z]*/)[1]; return units.split(":")[2];
If it's using the model time unit then you'll want to check that search finds a value and otherwise return the model unit.
Object p=Model.find("Processor1"); Variant v= p.getProperty("ProcessTime").match(/unitConversion:[a-z]*/); if (v.type==VAR_TYPE_ARRAY&&v.length>0) { string units=v[1]; return units.split(":")[2]; } return getmodelunit(MODEL_TIME);
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