Hello,
I am trying to create a named expression that will be used to control the display of context menus based on the model name prefix, (e.g. Sketch1, detail5.258, sectiont785) the user is in. My approach will only look at the prefixes and will include everything else after the prefix. I am wondering if anyone else has seen this issue before or how to fix it.
Below is the expression: (This expression works on correctly all models except the "Sketch" model. When testing in the "Sketch: model the result is "Can not evaluate expression.")
ActiveModel.Name = "Sketch" orSystem.String.Substring(ActiveModel.Name, 0,8) = "building" orSystem.String.Substring(ActiveModel.Name, 0,7) = "section" orSystem.String.Substring(ActiveModel.Name, 0,6) = "detail"
I have tried many variations of this expression, Such as
ActiveModel.Name = "Sketch" andSystem.String.Substring(ActiveModel.Name, 0,6) = "building" andSystem.String.Substring(ActiveModel.Name, 0,7) = "section" and System.String.Substring(ActiveModel.Name, 0,6) = "detail"
System.String.Substring(ActiveModel.Name, 0,6) = "Sketch" orSystem.String.Substring(ActiveModel.Name, 0,8) = "building" orSystem.String.Substring(ActiveModel.Name, 0,7) = "section" orSystem.String.Substring(ActiveModel.Name, 0,6) = "detail"
and
(System.String.Substring(ActiveModel.Name, 0,6) = "Sketch" orSystem.String.Substring(ActiveModel.Name, 0,8) = "building" orSystem.String.Substring(ActiveModel.Name, 0,7) = "section" orSystem.String.Substring(ActiveModel.Name, 0,6) = "detail")
Truncating the expression like this works but will not accomplish my end goal. I need the complete model names as there are different variations of these prefixes (i.e "building" and "build", and each require a different set of custom context menus).
System.String.Substring(ActiveModel.Name, 0,6) = "Sketch" orSystem.String.Substring(ActiveModel.Name, 0,6) = "buildi" orSystem.String.Substring(ActiveModel.Name, 0,6) = "sectio" orSystem.String.Substring(ActiveModel.Name, 0,6) = "detail"
It appears that the System.String.Substring does not like different length sizes within the same expression. any ideas on how to get my named expression to function using the full model prefix?
Thanks
-Mike
System infoWindows 8AECOsim Building Designer v10.00.00.154
Marc,Thank you for the reply. I have tried your suggestion, prior to my initial post. I did not notice that it was excluded that example in the posted. I have also tried it with out the carriage returns between each condition. The results are the same when testing the Sketch model. What Bentley software and version are you testing in?
Below is the named expression that I am testing
Models are:
Sketchsection.tempbuilding.tempdetail.temp
Regards,Mike
Hi Mike,
Just trying this out, I have not found a problem with lengths, although the values are case sensitive. This expression works and evaluates True/False with strings of 6 to 8 characters:
System.String.Substring(ActiveModel.Name, 0,6) = "Sketch" OR System.String.Substring(ActiveModel.Name, 0,6) = "sketch" OR System.String.Substring(ActiveModel.Name, 0,7) = "Section"OR System.String.Substring(ActiveModel.Name, 0,8) = "building"
So model names starting in
Evaluate True
evaluate False.
[the OR operator is not case sensitive, I just habitually type Booleans in upper case]
Regards
Marc