Named expression to check (raster) attachments

Hello,

I'm looking for a way to show/hide tools in the ribbon based on the presence of specific (raster) attachments. Can this be done by Named Expressions and if so, does somebody has an example for me.

Paul

 ~~

  • Hi,

    Can this be done by Named Expressions

    No and yes: No, because there is no such symbol available by default; and Yes, because such symbol / symbol provider can be (probably) developed (there is no technical reason why not).

    Probably the closest to your question can be an expression, testing whether a selected element is raster attachment (see IsRasterReference expression).

    I'm looking for a way to show/hide tools in the ribbon based on the presence of specific (raster) attachments.

    How it is expected to work? It's not clear to me:

    • What does it mean "presence of specific raster attachment"? The presence in e.g. view or that such raster is attached?
    • How the raster should be identified? By its name?
    • When the check should be done (when the raster is attached, when elements are selected...)?

    When show/hide rule is defined for ribbon control (tool), always two things have to be specified:

    • An expression providing boolean result (true / false) to define show / hide state.
    • When (using what sync event) the expression will be evaluated, because by default, they are evaluated only when the ribbon is (re)created (e.g. when a model is opened).

    With regards,

      Jan

  •       How it is expected to work? It's not clear to me:

    I've made a button to attach a raster reference. Once this reference is attached I want go change the button and its appearance to detach the reference. I was hoping this could be done by the use  of named expressions and the show/hide options in the ribbons.

  • Hi,

    thanks for the details, now the process is clearer.

    Once this reference is attached I want go change the button and its appearance to detach the reference.

    The process is quite complex at background, it's not (unfortunately) simple show/hide. Robust process should be:

    • There are two tools (icons) with opposite show/hide conditions.
    • Press button to start Attach raster tool with defined file to be attached and to start tracking of changes.
    • When the tracking ensures the right raster is attached, invoke the rule evaluation, so icons swaps.
    • Press button to start Detach raster tool with defined file to be detached and to start tracking of changes.
    • When the tracking ensures the right raster is detached, invoke the rule evaluation, so icons swaps back to the original state.
    I was hoping this could be done by the use  of named expressions and the show/hide options in the ribbons.

    When you ignore the robustness, which means to ignore whether the raster is really attached / detached, maybe it's possible (it's idea, not tested):

    For attach icon the key-in can be something like "raster attach <raster to be attached>;expand set BTN_RASTER_ATTACHED = 1" and for detach button "raster detach <raster file name to be detached>;expand set BTN_RASTER_ATTACHED = 0".

    Both icons have to set to use ModelChanged sync event (or explicit key-in "ribbon rebuild" has to be used) and also show/hide condition has to be set to evaluate BTN_RASTER_ATTACHED variable value.

    This approach does not check whether the raster is really attached, so button can change even when raster is e.g. missing. But it should work I guess ;-)

    With regards,

      Jan

  • Hi Jan,

    I'm still working on this 'problem' and working more or less towards your last suggestion. However, on testing my named expression whether a variable exists or has a value other than '1' , the expression cannot be evaluated.

    ConfigVar.GetExpandedConfigVar("BAG.XWMS")<>"1" OR NOT ConfigVar.IsConfigVarDefined("BAG.XWMS") 

    If I use one or the other expression before or after the OR operator it gets evaluated, but combined it doesn't work. Any suggestion on what's wrong in this expression?

    Paul

     ~~

  • Hi Paul,

    the expression is wrong and does not work, because when the variable is not defined, GetExpandedConfigVar cannot be evaluated. The variable can be processed only when is defined (in my opinion this implementation is not good, but we have to live with that ;-)

    At first, please defined the logic (expected results):

    • Variable is not defined ...
    • Variable is defined with value "1" ...
    • Variable is defined with other value than "1"...

    Regards,

      Jan