Strange Results with Text Insert Field when using Item Type Definition

I am using MicroStation CONNECT version 10.16.03.11.

I have created a custom Item Type with a property definition (type = text) called Length2D. Under calculated properties, I am using the following expression.

System.Math.Round(System.Math.Sqrt(this.GetElement().Segments[0].DeltaX ^ 2  + this.GetElement().Segments[0].DeltaY ^ 2),1)

So far, so good. I then attach my item type to a 3D line. Under the element properties dialog, I find my item type, and it is reporting the correct value with the correct precision (i.e., X.X). Next, when I go to annotate my line using a standard text element, and I choose the Insert Field option, then select my 3D line, then I locate my item type property definition...the resulting value gets all mixed up and is incorrect. It seems to get rounded unnecessarily.

Please note again that my item type property definition is "text". It shouldn't do any rounding. Also, everything is correct under the element properties for my item type. The "bug" or issue appears to occur when the user tries to annotate the item type definition using a text field.

Does anyone have any ideas of a workaround to fix this issue? For example, are there any unpublished functions within the item type expression builder that fully commits a variable to strict text? I am grasping at straws here, but say like in VBA where you can use a function like STR to convert a number to a text. I am not sure this would solve my problem because again, everything is fine in the element properties dialog, but when I go to use this data and display the results graphically, then MicroStation "hiccups".

3D Imperial Design.dgn

 

Parents Reply Children
  • Hi Leonard,

    Based on actual read-world construction tolerances, I need to calculate the 3D line slope using the method and assumptions (or input parameters) I mentioned in my message above (Wed Sept 27 11:34 AM). Restated, here are the assumptions and calculation parameters:

    • Find the elevation values of the beginning and end of the line. Round these to two decimal places (i.e., X.XX). Calculate the elevation difference between these two points.
    • Query or calculate the 2D length of the line. Round this value to one decimal place (i.e., X.X).
    • Calculate the slope of the line (i.e., Rise / Run). Then round the slope value to one decimal place.

    This is a real world scenario for linear transportation projects such as the design and construction of ADA complaint pedestrian access ramps. Here is an example:

    Please note that there are subtle but important differences in the result of the calculated slope values using the method I outlined above, versus your proposed solution that allows MicroStation to use as much precision as possible (e.g., full double precision values of elevations and line lengths, etc.), and then at the very end attempting to round up the slope value. For example:

    • 1.6% (my calculation process) versus 1.5% (your proposed solution)

    Due to ADA compliance, and some state and DOT regulations, for certain aspects of pedestrian ramps the 1.6% slope would be non-compliant and if built and installed this way, the ramp would need to be torn out and reconstructed.

    Can you or someone else at Bentley check or confirm why MicroStation cannot display the instance data of the item type definition Slope as noted in this screen grab?

    The expression is working correctly in the item type, and it displays correctly in the element properties window, but there appears to be a bug within MicroStation for the step that involves the "lookup or query" of the corresponding Text Field.

  • Thanks for sharing all the details. I am checking with Development on this.

    The problem is with Round function which results to 0. The Round function does not round decimal values.
    System.Math.Round(this.GetElement().Segments[0].DeltaZ, 2)

    To round the decimal values, I had to use the following expression which results to 0.4. Check link
    System.Math.Round(System.Math.Abs(this.GetElement().Segments[0].DeltaZ) * 100)) / 100

    Check the attached DGN, I split the expressions for easy handling.
    MyLib > LinearProp
    Rise - System.Math.Round(System.Math.Abs(this.GetElement().Segments[0].DeltaZ) * 100)) / 100
    Run - System.Math.Sqrt(((this.GetElement().Segments[0].DeltaX ^ 2) + (this.GetElement().Segments[0].DeltaY ^ 2)))
    Slope - (this.GetItem("DgnCustomItemTypes_MyLib:LinearProp")["Rise"] / this.GetItem("DgnCustomItemTypes_MyLib:LinearProp")["Run"]) * 100
    Slope - (this["Rise1"] / this["Run"]) * 100

    5383.test.dgn

  • Thank you Leonard! The research you performed, and in particular, the link you found with the solution to the issue with that Math.Round function did the trick!

    I implemented your solution by updating my item type property definitions. To provide full robustness, I even incorporated the ability to change the "precision" (number of decimal places) for the rounding of the Rise and Run calculations.

    Please note that that the best work-around I found for the rounding of the Slope calculation is to use the System.String.Format function, and I even provided flexibility to make this adjustment after applying the item type to the 3D line. For example:

    • To round slope to one decimal place: {0:#.#}
    • To round slope to two decimal places: {0:#.##}
    • Etc.

    In the event that anyone else is following along, or would find this useful, attached is the updated DGN file with the item type property definitions.

    Thanks again Leonard for all your help with this solution!

    3D Imperial Design-Updated_V3.dgn

    Answer Verified By: Matthew Ashby