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
Try System.String.Format. Check help.
System.String.Format ("{0:#.#}", System.Math.Round(System.Math.Sqrt(this.GetElement().Segments[0].DeltaX ^ 2 + this.GetElement().Segments[0].DeltaY ^ 2),1))
Hi Leonard. Thank you for the suggestion. I gave it a try, but unfortunately it produced the same incorrect result as I noted in my original post.
As best I can tell, the calculations are being performed correctly in my item types. As I mentioned above, the correct values show up through the element properties dialog. However, there is a bug or issue when attempting to display the item type definitions via the place text \ insert field method. Rather than the software just going and "looking" or "grabbing" the values from the element properties window for the corresponding item type definition, it seems like the software is attempting to re-calculate all the item type definitions and then decides to add an extra layer of rounding to the results before applying it to the graphical piece of text.
This is very frustrating. The correct value is there under the element properties window, but there is no easy way to display this information to the user, or an eventual client via a detail plan sheet, etc.
Matthew Ashby said:System.Math.Round(
doesnt the round part round the answer, sorry I'm not expert in the strings thing .. but hey wouldnt it be better to use a data Field so you could define in the text as lenght and set the number of decimal point and have it associated to the element.. without using item types
Lorys
Started msnt work 1990 - Retired Nov 2022 ( oh boy am I old )
But was long time user V8iss10 (8.11.09.919) dabbler CE update 16 (10.16.00.80)
MicroStation user since 1990 Melbourne Australia.click link to PM me
Hi Lorys. I don't think Text Data Fields would work. Unless I am missing something, the data fields are sort of "dumb" objects that cannot be assigned to "read" or look up element properties. What I am chasing after is an "intelligent" text that can read information from my Item Type definitions (that have some basic math calculations performed within the expression builder of the item definition). If the user extends or shortens the line, then the corresponding text annotation value would update and report the new 2D length of the line element object (which will be a 3D line).
Stated another way...I am trying to create a custom Dimension Element, but instead of using the restricted options that are pre-defined (e.g., length, angle, radius) as part of the Dimension Elements, I want to "pull/grab" the result of an Item Type Definition. In theory this should work with Text \ Insert Field process, but as I have discovered, there seems to be a "bug". If possible, it would be nice for someone from Bentley to acknowledge this, and then get it added to the pending issue resolution list.
ok were saying the same thing now without using item types, bring up the text editor type Length2D=
but next use the insert field ( this is a text data field not an Edit Data Field old school tech) and choose length option property and set the decimal places then it will ask to assign the text to which element. once completed if you lengthen or shorten the element by its grab handles you will get the text to auto update.. Yes the item types or tag method will allow you to do reports but what other things do you want to report , total lengths of all lines ? can be done by select by attributes and level or colour to create selection or via vba but IMHO select by is easier.
look here example in ask inga ( they use area but length for lines is available as well as radius for circles and arcs etc
Text fields
Lorys said:wouldnt it be better to use a data Field
Data fields, as you probably know, are an antiquated method of speeding annotation.
Matthew Ashby said:Unless I am missing something, the data fields are sort of "dumb" objects
Correct!
Item Types were introduced with MicroStation CONNECT and have improved and grown less buggy over the years as new Updates are introduced. Item Types let you attach data, or calculate data, about a DGN element, model or file.
When you attach an Item Type to an element, or something else, it's termed an Item instance. That instance is invisible, but you can see its value in the Element Properties dialog.
Also improved with MicroStation CONNECT are Fields. A field lets you materialise an Item instance by displaying its value as text. Unlike an Enter Data field, a Field is smart and updates automatically when the Item instance changed. That is what Matthew is attempting, and it mostly works but a glitch has appeared.
Matthew Ashby said:If the user extends or shortens the line, then the corresponding text annotation value would update and report the new 2D length of the line element
That's what should happen and, in my experience, does happen.
Lorys said:use the insert field ( this is a text data field not an Edit Data Field old school tech) and choose length option property
Yes, Fields can be used to display a DGN property as well as Item instance data.
Lorys said: the item types or tag method will allow you to do reports
You can create a Report from DGN properties. An element doesn't have to be tagged or have Item data to participate in a Report. Here are examples of Reports. The examples report on DGN properties. They don't include Item Types because I wanted to dispel the misconception that Reports are only meant to work with Item Types.
Regards, Jon Summers LA Solutions
Thanks Jon I meant insert Text field not Edit Data Field which I later made clearer in the later post. The OP implied he tried items but was getting rounding errors, and was not working right when pulling the grab handles.. thanks for pointing out reports can be done without items, I learnt something new.