During the porting from V8i to CE, we intent to use a specific custom workflow that will take the place of the goold old menu.
This workflow is created and loaded dynamically (it will even change when the user changes DGN).
In order to do so, we build an XML file and import it from within an MDL application.
There are 2 problems:
1)
An eventual existing workflow with the same name is not overwritten but some sort of duplication is created. We could call ribbon customizations revertall first, but that deletes all customizations and we don't want that. We just want to delete the workflow with that specific name (without the user being asked anything).
2)
The key-in ribbon customizations importecxml opens a dialog asking the user to enter the filename. If I pass the filename within the command, it just asks me if I want to import the xml into Personal.dgnlib and it doesn't add the workflow to the ribbon. We want to import an XML without the user being asked anything.
Any suggestions?
Thanks,
Robert Kock
Hi Robert,
in my opinion it's about misunderstanding of purpose of "customization XML file" usage (as I understand it).
Ribbon customization tool provides limited (user level) access to ribbon definition. XML file, exported file serves more for storing the customization as a backup, plus optionally to migrate the customization between the files. But it's not designed to be used as dynamic runtime change tool of the ribbon at a runtime.
Robert Kock said:An eventual existing workflow with the same name is not overwritten but some sort of duplication is created.
I guess exact overwriting definition is allowed only in ribbon definition, described in MicroStationAPI help (which I recommend to you already).
Robert Kock said:We want to import an XML without the user being asked anything.
You are using wrong tool. Ribbon customization is the tool designed to be used by users, not by applications at runtime.
Robert Kock said:Any suggestions?
I wrote it in another discussion already: When you want to change completely ribbon completely dynamically, ribbon NET API is probably the only way to go. The problem is that it's not well documented, so it can be a bit adventurous (personally I think it's doable).
As a workaround, even when I think it's quite dirty, is to modify ribbon xml definition at runtime (do not confuse this file with customization EC xml file). It requires to be very precise to do not break exact XML format (plus XSD definition), but as far as I remember, when ribbon is reloaded (which is huge and quite expensive operation), xml file(s) is reloaded and current content is used.
And as third, because you have still not provided any proof it's not possible, can be fully standard way to define a set of ribbon customizations (in ribbon xml) and to control it's visibility using expressions and show/hide conditions.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Jan is absolutely correct about the purpose of the XML files.
Potentially simpler alternatives (depending on what you want to do) are:
Regards
Marc
OK. I got the point.
So let's assume I compose the ribbon statically with all possible elements (tabs, groups, buttons, dropdown buttons, submenus) enabled.
As soon as the user selects a DGN, I need to evaluate which items need to be shown/hidden/enabled/disabled. This depends on the permissions of the user and the DGN itself (for instance, another user may have opened the same DGN). This information is found in our database. The DGNs themselves are also stored in the DB and a DGN is download when the user selects it.
I understand I need named expressions for this but in fact I would like to have some kind of callback that is invoked for each element.
In the API documentation I found the functions mdlNamedExpression_EvaluateAs* but I'm not sure when and how these functions are called.
Robert
Robert Kock said:but in fact I would like to have some kind of callback that is invoked for each element.
It seems you (still) have not read ribbon documentation, available in MicroStationAPI, as I recommended in another thread.
There is synchronization system available that ensure every show/hide condition of every ribbon control is evaluated when specific event (standard or custom one) is raised.
Regards,