8 Replies Latest reply on Nov 2, 2016 8:30 AM by beltz

    Problem in setting Variant Manager settings - ConfigFile - if the existing ConfigFile is invalid

    beltz

      I'm following an example in the Variant Manager Automation manual; under VMSettings Object, Example 2-1 Settings Example.

       

      Among other things I'm try to set ConfigFile to a certain filename.  But I've found that if the existing ConfigFile value is invalid (blank or invalid filename) then it doesn't set the ConfigFile value to what I'm specifying in the code.  When I run the program which opens Variant Manager (and the existing ConfigFile value is invalid) and attempts to set this value, I get an error message in red in the Variant Manager window that says:

      Library source data configuration file not defined. Use Settings to define.

       

      I get this message when it executes

      Set toolSettingsObj = settingsObj.LibQuery

      and when it executes

      toolSettingsObj.ConfigFile = "/home/dms_lib/WDIR795/DXDBLex.dbc"

       

      NOTE: I'm running on RedHat Enterprise Linux.  I get this same behavior when running the program in DxDesigner and ExpeditionPCB.

       

      NOTE: If the existing ConfigFile value is valid, then it will change the ConfigFile value to what is specified in my program.

       

      Also I'm noticing that the Variant Manager Enumerated Types don't appear to be available in my program, even though I am loading them with (for VX.1)

      Scripting.AddTypeLibrary "MGCVARIANTGUI.MGCVariantGUICtrl.2"

       

      So instead I have to use the constant numerical values.

       

      Option Explicit

       

          Dim vmaddin   ' The Variant Manager Addin object

          Set vmaddin = Application.Addins("Variant Manager")

          ' if vmaddin Is Nothing then Addin not already loaded, so load it now

          If vmaddin Is Nothing Then

            Set vmaddin = Application.Addins.Add("MGCVARIANTGUI.MGCVariantGUICtrl.2", "Variant Manager", "")

            vmaddin.Visible = True

          Else

            vmaddin.Visible = True

          End If

              ' Load TypeLibrary so that Variant Manager Enumerated Types are available

          Scripting.AddTypeLibrary "MGCVARIANTGUI.MGCVariantGUICtrl.2"

         

          Dim settingsObj, toolSettingsObj

              Set settingsObj = vmaddin.Control.VariantGuiApplication.Settings

              ' General Setting

              Set toolSettingsObj = settingsObj.General

              toolSettingsObj.ReportTxtDelimiter = ""

          ' the following didn't work

              'toolSettingsObj.ReportViewExcel = eVMOptionOff

          toolSettingsObj.ReportViewExcel = 0

         

          'toolSettingsObj.ReportViewHTML = eVMOptionOff

              toolSettingsObj.ReportViewHTML = 0

              toolSettingsObj.UnplacedKeyword = "NO-POP"

              ' PCB Setting

              Set toolSettingsObj = settingsObj.PCB

          'toolSettingsObj.FablinkActionPrompt = eVMOptionOn

              toolSettingsObj.FablinkActionPrompt = 1

         

              'toolSettingsObj.FablinkDataGenerationMode = eVMFXEOnRequest

          toolSettingsObj.FablinkDataGenerationMode = 3

              toolSettingsObj.UnplaceAssKeepOutline = 0

              toolSettingsObj.UnplaceAssKeepPartnum = 0

              toolSettingsObj.UnplaceAssKeepRefdes = 0

              toolSettingsObj.UnplaceSilkKeepOutline = 0

              toolSettingsObj.UnplaceSilkKeepPartnum = 0

              toolSettingsObj.UnplaceSilkKeepRefdes = 0

              toolSettingsObj.UnplaceSolderMask = 0

              toolSettingsObj.UnplaceSolderPaste = 0

              ' CAE Setting

              Set toolSettingsObj = settingsObj.CAE

              Call toolSettingsObj.SetMarkupColor (0, 0, 0) 'black

              Call toolSettingsObj.SetUnplaceColor (0, 0, 0) 'black

          'toolSettingsObj.PackageUnplaceOption = eVMCAEPackUnplaceMarkup

          toolSettingsObj.PackageUnplaceOption = 2

              ' Library Setting

          MsgBox("Before LibQuery")

              Set toolSettingsObj = settingsObj.LibQuery

          MsgBox(toolSettingsObj.ConfigFile)

              toolSettingsObj.ConfigFile = "/home/dms_lib/WDIR795/DXDBLex.dbc"

              toolSettingsObj.MaxResultsPerLib = 10

              toolSettingsObj.MaxResultsTotal = 22

              toolSettingsObj.PartNumberAttribute = "Part Number"

              toolSettingsObj.RowFormatter = "$(Part Number)"

              toolSettingsObj.SummaryInfoFormatter = "$(Part Number)"

        • 1. Re: Problem in setting Variant Manager settings - ConfigFile - if the existing ConfigFile is invalid
          Patrick.Cashman

          Perhaps I'm missing the point of your question but is it not a fairly simple matter of file IO to verify in advance that the filename is correct? And if there is no such file, to copy one from a template area or some other safe repository?  If the function works as expected when a valid file is present I don't know what, other than an error message, could happen when a valid file is not present.

           

          Regarding the issue of enumerated values, perhaps it's my ignorance or poor practice but I always use the numeric constants.  It has seemed to me that they are no more likely to change over time than the enumerated values are for any given function. While it is true that the code is no longer human-readable, the help files are just a few clicks away at any moment, so if I need to, I can review them readily.  Also it's easier for me to remember the numeric values when re-using a function.  Just my 2 cents, but again, for me, this is simpler.   Perhaps years ago when I started writing scripts for Mentor I discovered the same as you, missing or incorrect enumerations, and just said, "It's easier and more reliable to use the integers." and thus that became my practice.  I do have some faint memory of some early problems with them.  Entirely possible. If so, that's the (Mentor) world we live in.  Roll with it.

          • 2. Re: Problem in setting Variant Manager settings - ConfigFile - if the existing ConfigFile is invalid
            beltz

            Thanks for the info.

            Yes I ended up just adding a step before invoking Variant Manager to copy a good VmgrLdataGrid.cfg file into the design, so that there would be a valid ConfigFile to start with, so that the program will work.  But of course the whole point is to use the program/automation to set these settings.  In fact, I might have been able to do this for all the VM settings; copying in a good default .cfg file. 

            The VM Settings are contained in various .cfg files.

            VmgrCommon.cfg

            VmgrDxd.cfg

            VmgrExpPCB.cfg

            VmgrLdataGrid.cfg

            My point for posting the question was to get any advice on something I was doing wrong in my program. I'm not really a VBScript expert, yet. I'll probably write an SR on this and see if anything happens.

             

            On the enumerated values, I went your route and added Const definitions for them.  Again, I thought perhaps I was doing something wrong in my program, to not get them to show up when using

            Scripting.AddTypeLibrary "MGCVARIANTGUI.MGCVariantGUICtrl.2"

             

            I appreciate your comments and yes, I've very familiar with working around MGC shortcomings.

             

            Walt

            • 3. Re: Problem in setting Variant Manager settings - ConfigFile - if the existing ConfigFile is invalid
              Patrick.Cashman

              One thing you might look at is the .2 in your Scripting.AddTypeLibrary "MGCVARIANTGUI.MGCVariantGUICtrl.2" command.  That may not be the correct prog_id.  You most likely know that each version of the Mentor tools has its own prog_id.  I get that on the fly from the registry. I know you're using linux, so you'll have to use the corresponding environment settings to get it.  I'm no help there as I haven't worked in any unix/linux environment for years.

              • 4. Re: Problem in setting Variant Manager settings - ConfigFile - if the existing ConfigFile is invalid
                beltz

                Hi

                I was just going by what's in the Variant Manager Automation Reference,

                Example 1-1 Variant Manager Addin where it explicitly says:

                 

                With the introduction of VX.1, you must use the following library for any

                scripts that invoke the

                MGCVariantGUICtrl library:

                 

                MGCVariantGUICtrl.2

                 

                I've submitted an SR to MGC, so I'll let you know what they say.

                 

                Thanks

                Walt Beltz

                Lexmark International Inc

                Lexington, KY

                • 5. Re: Problem in setting Variant Manager settings - ConfigFile - if the existing ConfigFile is invalid
                  beltz

                  I have some more information on the problem of using the enumerated values and the use of Scripting.AddTypeLibrary "MGCVARIANTGUI.MGCVariantGUICtrl.2" to access them.

                   

                  From a response I received on my SR from MentorGraphics there is a COM version number that goes with each MGC release.They referenced TechNote MG588916 Automation - Using COM Version Number in VX

                   

                  VX.1.2

                  COM Version number 26

                   

                  VX.1.1

                  COM Version number 9

                   

                  I'm using VX.1.2 and when I used the following I was able to use the enumerated values.

                  Scripting.AddTypeLibrary "MGCVARIANTGUI.MGCVariantGUICtrl.26"

                   

                  Walt

                  • 6. Re: Problem in setting Variant Manager settings - ConfigFile - if the existing ConfigFile is invalid
                    beltz

                    Thanks. It looks like that was the issue with the enumerated type names

                    missing. I added this info to my thread on communities.

                     

                    I have some more information on the problem of using the enumerated values

                    and the use of Scripting.AddTypeLibrary "MGCVARIANTGUI.MGCVariantGUICtrl.2"

                    to access them.

                     

                     

                     

                    From a response I received on my SR from MentorGraphics there is a COM

                    version number that goes with each MGC release.They referenced TechNote

                    MG588916 Automation - Using COM Version Number in VX

                     

                     

                     

                    VX.1.2

                     

                    COM Version number 26

                     

                     

                     

                    VX.1.1

                     

                    COM Version number 9

                     

                     

                     

                    I'm using VX.1.2 and when I used the following I was able to use the

                    enumerated values.

                     

                    Scripting.AddTypeLibrary "MGCVARIANTGUI.MGCVariantGUICtrl.26"

                     

                     

                     

                    Walt

                    • 7. Re: Problem in setting Variant Manager settings - ConfigFile - if the existing ConfigFile is invalid
                      Patrick.Cashman

                      You're welcome.

                       

                      You may want to consider getting the COM Version (what I was calling prog_id) programatically, so that you don't have to fix code in your application when you upgrade to a new version of Mentor software.  As I said, I get it from the registry.  Not sure how you would do it in linux, but I bet it's stored somewhere in the environment or some config files.

                      • 8. Re: Problem in setting Variant Manager settings - ConfigFile - if the existing ConfigFile is invalid
                        beltz

                        Yes I tried using the example code from the TechNote to figure out the

                        correct prog ID to use, but it didn't run on Linux.