I want to perform an area calculation in an Item Type property using an Expression. Here's the expression to get the element area:
this.GetElement().Area
However, it looks like that area is expressed in DGN units of resolution (UORs). I want to divide the element's area by UORs². How should I extend the expression get the value of UORs in the DGN model where the element lives? If the element is in a reference attachment I want that model's UORs, not the active model's UORs.
Hi Jon,
According to really good PDF guide attached to the recent blog post about Item Type EC Expressions (here: https://communities.bentley.com/products/microstation/b/microstation_blog/posts/ec-expressions-in-item-types---new-in-microstation-connect-edition-update-12), a variant of the expression below should get you what you need.
this.GetModel().Resolution
Seeing that there is a Named Expression for the model of a selected element I would expect there to be some solution that works here based on what ive seen so far:
Regards,
Mark
OpenRoads Designer 2023 | Microstation 2023.2 | ProjectWise 2023
Mark Shamoun said:According to really good PDF guide attached to the recent blog post
Thanks! I hadn't noticed that PDF.
Mark Shamoun said:the expression below should get you what you need
I had sought SubUnits, UORs and UnitsOfResolution, but not simply Resolution. Thanks again!
If I use just this.GetModel().Resolution in an expression, it appears correctly in a text field. When I use it in a calculation, I see #### in the text field. For example, this multiplication doesn't seem to work:
this.GetModel().Resolution * this.GetModel().Resolution
Nor this calculation to obtain the element area in master units:
this.GetElement().Area / (this.GetModel().Resolution * this.GetModel().Resolution)
According to the documentation in the PDF Mark cited, expression Resolution is type System.String. If I put this.GetModel().Resolution in a Text property then I see something like 10000 per Distance Meter. So Resolution is a description, not a number.
Resolution
System.String
Regards, Jon Summers LA Solutions
Jon Summers said:So Resolution is a description, not a number.
Yes, this problem was discussed some time ago already.
In Named Expressions, the problem can solved (partially) using expression
System.String.Substring(ActiveModel.Resolution,0,System.String.IndexOf(ActiveModel.Resolution," "))
that separates number from the resolution description.
Unfortunately other problems remain:
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Jon Summers said:I want to divide the element's area by UORs²
How do I obtain the numeric resolution of a DGN model to use in an Expression? Would a knowledgeable person from Bentley Systems care to comment?
It seems that the example Jan posted above may be the only method thats close to do what you need - have you tried it?