I haven't looked at your script yet - if you have added the "MGCVARIANTGUI.MGCVariantGUICtrl.2" library as in the example from the EEVX.1 xPCB Automation manual, I suggest that you log a Service Request for this issue - it may be a bug..
I have checked the code and don't believe it's an issue, because I cannot get the eVMOperNone case to exist. If I set a component to CNI (we use this for "Component Not Installed"), it fires the eVMOperUnplace case. If I replace the part number, it fires the eVMOperReplace case. If I reset to no action, the eVMOperNone does not happen.
A small difference is that I use the integer value of the constants instead of the constant name.
Here is the code:
For Each vmcompmod In vmcompmods
if vmcompmod.Operation = 0 then
Debug.Print("component " & vmcompmod.Component.Name & " has cmcompmod.operation = 0")
if vmcompmod.Operation = 1 then 'selects out the unplaced components
unplaced.Add(vmcompmod.Component.Name) 'adds the unplaced components to the unplaced arraylist
if vmcompmod.Operation = 2 then 'selects out the replaced components
The first one, = 0, never happens. And I get no errors when I compile or run.
So I suggest you use the integers, and then verify if it actually ever happens or not. If not, then remove that section of code.
I'm curious to find out what you discover.
Thank you Patrick for your hint.
If I use the integer values (0 = eVMOperNone, 1=eVMOperUnplace, 2=eVMOperReplace) instead of the ENUM Types mentioned in the automation user book it works in both versions EE7.9.5 and EEVX.1.
If I use any ENUM type like eVMOperUnplace or eVMOperReplace instead of the integer values I get the same error message for the first ENUM Type.
eg. If I replace eVMOperNone with 0, then the first error appears with eVMOperUnplace as not defined variable.
If I replace eVMOperNone with 0 and eVMOperUnplace with 1 then the error comes with eVMOperReplace
If I change all values to integer constants - everything works perfect.
So it looks like a bug from Mentor! Maybe the ENUM Types are not public anymore?!?
In every case where there is this kind of enumerated set of possible values, that have an integer counterpart, I always use the integer. Some have a hex value, so I use that. Never the enumeration strings. I can't remember when or why I started doing that, but I suspect it was because long ago I encountered one that did not work, found that the integer did work, and went with that from that point on.
Since I self-taught VB, and don't know all the 'rules', there is probably some fundamental principle I'm violating by doing this. But oh, well. It works.
In VX releases, you must specify the correct progid in the objects, IE:
From an opened application:
Dim sComVersion : sComVersion = Scripting.GetEnvVariable("EXP_PROG_ID_VER") : If sComVersion = "" Then sComVersion = "1"
Dim progID : progID = "MGCVARIANTGUI.MGCVariantGUICtrl." & sComVersion
Set addinObj = launchAddin(progID, addinName, associatedScript,addinPlacement, shortcutKey)
Scripting.AddTypeLibrary("MGCVARIANTGUI.MGCVariantGUICtrl." + sComVersion)
This will get you access to the enums.
Thanks for your answer - I did that, but this did not help.