Unit objects are used to establish a unit system within a project. A project can have one or more unit systems. If no Unit object is defined, the entire project is assumed to be in a single unit system.
The first Unit object must be named 'Internal' and is used to define the internal unit system of the project. Having a consistent internal unit system makes it easier to write parametric expressions.
Once an internal unit system is defined, it's possible to create additional unit systems to make input easier for the end user. For example, the author of the project can create multiple unit systems named 'Section', 'Coordinate', 'Displacement' etc. Any parameter that has a unit category that matches the name of the Unit object will use that particular Unit system for end-user input. The Unit object named 'Internal' will be used for internal computation.
If a Unit object named 'Default' exists in the project, all parameters that do not have a defined unit category are assumed to be in the 'Default' unit category.
Example Syntax
... <O T="Unit"> ... ... </O>
Example:
<O N="Unit_Object1" T="Project" Category="Core Objects"> <!-- created by ParamML Examples on 27.01.2023 --> <O N="Internal" T="Unit" Length="Millimeter" Force="Newton" Angle="Radian" Temperature="Fahrenheit" /> <O N="Geometry" T="Unit" Length="Meter" Force="Newton" Angle="Degree" Temperature="Fahrenheit" /> <O N="Property" T="Unit" Length="Centimeter" Force="Newton" Angle="Degree" Temperature="Fahrenheit" /> | |
Once three "Unit" objects have been created in the project as described above, we can assign a specific parameter to a created parameter by specifying its Unit Category (UC) and Unit Type (UT). The Unit Category (UC) specifies the name that the parameter will be assigned to, while the Unit Type (UT) indicates what the parameter represents. If the Unit Category (UC) matches the name of one of the "Unit" objects, the parameter will use the unit system that it matches. | |
<O N="Unit_Object1" T="Project" Category="Core Objects"> <!-- created by ParamML Examples on 27.01.2023 --> <O N="Internal" T="Unit" Length="Millimeter" Force="Newton" Angle="Radian" Temperature="Fahrenheit" /> <O N="Geometry" T="Unit" Length="Meter" Force="Newton" Angle="Degree" Temperature="Fahrenheit" /> <O N="Property" T="Unit" Length="Centimeter" Force="Newton" Angle="Degree" Temperature="Fahrenheit" /> <O N="Inputs" T="Group"> <P N="A" V="-1000" Role="Input" Category="Inputs" UT="Length" UC="Property" /> <P N="B" V="100" Role="Input" Category="Inputs" UT="Length" UC="Geometry" /> <P N="C" V="50" Role="Input" Category="Inputs" UT="Angle" UC="Internal" /> </O> </O> | |
Parameter A will specify a length (UT) and its unit will be centimeters.
|
To view this example in the library, see (https://openbrim.org/platform/?application=inc&author=ParamML_Examples_OpenBrIM+Platform&obj=objidaapg7ixwv54fcui4dieivp)
Example:
<O N="Unit_Object2" T="Project" Category="Core Objects"> <!-- created by ParamML Examples on 30.01.2023 --> <O N="Units" T="Group"> <O N="Internal" T="Unit" Length="Inch" Force="Kip" Angle="Radian" Temperature="Fahrenheit" /> <O N="US_Route1" T="Unit" Length="Feet" Force="Kip" Angle="Radian" Temperature="Fahrenheit" /> <O N="US_Route2" T="Unit" Length="Yard" Force="Kip" Angle="Radian" Temperature="Fahrenheit" /> <O N="US_Route3" T="Unit" Length="Mile" Force="Kip" Angle="Radian" Temperature="Fahrenheit" /> </O> <P N="X1" V="36000" UT="Length" UC="US_Route2" /> <P N="X2" V="63360" UT="Length" UC="US_Route3" /> <O N="Check" T="DesignCode"> <P N="TotalX" V="X1+X2" UT="Length" UC="US_Route1" /> </O> </O> | |
For example, the road unit system defined above can be used in US Highway projects. These unit systems can be added, removed, or modified, except for the 'Internal' unit system. This is because, as the code is executed, it converts all unit systems into a single unit system (internal unit). All other unit systems (Display Units) are units of parameters that the end user sees. As the code runs, all the unit systems that the user sees are converted to the Internal unit system. | |
As stated above, the unit systems for the two parameters X1 and X2 are different. The end user sees this as X1=1000 yards and X2=1 mile, and inputs these values accordingly. | |
The entire process is carried out using the Internal unit category. In this example, since the Internal unit system, with a Unit Type of Length, uses millimeters, X1=36000 inches and X2=63360 inches are converted to the units that the user wants to view. |
To view this example in the library, see (https://openbrim.org/platform/?application=inc&author=ParamML_Examples_OpenBrIM+Platform&obj=objidglgw5fxfrq5ojunf8ebkw)
Add Comment