Home Image-Pro Automation (Macros, Apps, Reports)
Options

How can I modify a FibreApp parameter from a Macro?

Thanks for reading,

I am making an ap in which a set of images are processed and then fibres counted by the FibreSeparationApp. However I need to change the settings of the app from inside the macro depending on the image's properties.

Is there anyway to achieve this? Thanks in advance!

Best Answer

  • Options
    Answer ✓
    David,

    You have to use the new version of the app, attached to my previous post, it has ReloadOptions sub.

    Yuri

Answers

  • Options
    Hi David,

    You can freely modify the code of Fiber Separation app or add new functions. Check the code to see what variables correspond to the properties of interest. So, you can make the app use your parameters (based on image properties).

    Yuri
  • Options
    Thanks Yuri

    However the reason I ask is because I am not an VB expert and even when I can see the code, I don't know how to access the variables of the Fibre Separation app from another macro.

    First I tried recording a Macro, but when I make any changes in the Fibre App paramenters, nothing appears in the macro. Then I tried using the names of the variables as if they were global, but of course shows an error.

    I guess there should be a simple way to access those variables, but I don't know how.

    Any further advice would be appreciated.

    David

  • Options
    Hi Yuri

    I tried using 

    With  ThisApplication.Settings("FiberSeparationApp")
                        .Set("LineTickness",100)
    This somehow sets a value that later can be verified with a similar var=.get("LineThickness") line.

    However the fibre separation panel is not updated and the fibre separation takes place with the value that remains visible in the panel.

    The worst is that even after measuring the fibres with the panel value, .get("LineThickness") line still gives back the original value as 100 above.

    Seems to me that there is two working values and I am accessing the wrong one.

    Any help would be appreciated.

    David


  • Options
    Hi David,

    Your attempt of using settings was good, but it would require reloading the settings to the dialog in the Fibers app, which was missing (you also misspelled option name "LineThickness"), otherwise the settings you set would be used only next time the app was loaded.

    I've modified the app (attached) exposing "ReloadOptions" sub, which can be called externally to reload the options from settings.

    Here is the test macro, which you can use:
        Public Sub SetFiberOptions()
            With  ThisApplication.Settings("FiberSeparationApp")
                .Set("LineThickness",99)
            End With
    
            'load new options to Fiber Separation app
            With Automate.ScriptingCommands.PlayMacro(Nothing)
                .MacroFile = "FiberSeparation>ModuleFiberSeparation.vb"
                .MacroName = "ReloadOptions"
                .Run(Nothing, Nothing)
            End With
        End Sub
    
    

    Yuri
  • Options
    Hi Yuri

    I tried to use your code but it keeps using the value from the panel that does not change as the code runs.

    Does it have to be running in a PUBLIC SUB or it can also be running from a PUBLIC FUNCTION? I think they are the same for this matter.

    Any further advise would be appreciated!

    David
  • Options
    Hi Yuri

    Thanks for your support, I really appreciate your help!

    I just noticed that when you call a macro with the PlayMacro it doesn't give you an error when the macro does not exist. I say this because the FibreSeparation app does NOT have a macro called ReloadOptions.

    Please let me know your thoughts,

    David
  • Options
    Hi Yuri

    It works very well indeed! I think I had two versions of the FibreApp downloaded in the same folder and I was using the old one. Your modified version works quite well.

    I really appreciate all this help. Hope you are up for some well deserved holidays and have a good time!

    Thanks a lot!

    David
Sign In or Register to comment.