Using AECOSIM CONNECT UPDATE 1 | Windows 8.1
Trying to customize some ribbon buttons using Named expressions. What I want to do is recognize a portion of a file name and if it matches show a button and if not don't show a specific button.
I have spent a significant amount of time and tried many different possibilities (substring, length -, getfilenamewithoutextension and others) and all have given me grief.
I feel the approaches below have been the most promising, because the individual pieces seem to work. However when I combine and click the Test button to evaluate, I get a "can not evaluate expression" error instead of a true or false.
System.String.IndexOf(ConfigVar.GetExpandedConfigVar("_DGNFILE"), ”_GUI.DGNLIB”) > 0
System.String.IndexOf(System.String.ToString(ConfigVar.GetExpandedConfigVar("_DGNFILE"), ”_GUI.DGNLIB”)) > 0
What am I doing wrong?
Thanks in advance
Keith
Figured out my own solution add to incorporate a system.string.substring and do a compare to the string returned. as shown below.
System.String.SubString(ConfigVar.GetExpandedConfigVar("_DGNFILE"), System.String.IndexOf (ConfigVar.GetExpandedConfigVar("_DGNFILE") , "_GUI.DGNLIB"), -1)="_GUI.DGNLIB"
Thanks to anyone who was looking into.
Hi Keith,
I was not able to answer earlier because of different time zone. It's good to know you found the solution, but in my opinion it can implemented in better way.
I see two situation when the used approach will not work properly:
There is another solution using different approach:
System.String.CompareI(System.String.Substring (ConfigVar.GetExpandedConfigVar("_DGNFILE"),System.String.Length(ConfigVar.GetExpandedConfigVar("_DGNFILE"))-11, -1),"_GUI.DGNLIB")
To decode this train wrack (which is usually treated as dirty code, but there is no other solution how to keep everything in one line ;-)
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Thank you Jan! After reading and testing out your reply I have adjusted my solution to match yours because it is much more flexible.