7 Replies Latest reply on Dec 18, 2014 2:26 AM by delinquent

    About DxDesigner Automation Script




      I am using OnVariantChanged Event.I want event to be triggered on any changes in Variant name or description.But It is not not getting triggered.And I am not finding cause. any one have idea?

        • 1. Re: About DxDesigner Automation Script

          Hi Sanjay,

          Please post the code you try to run.


          I guess it should look like:


          Sub Application_OnVariantChanged(Name, oldName, Operation)


               your code


          End Sub

          • 2. Re: About DxDesigner Automation Script


            I discussed this with Sanjay last week - we had the proper code figured out, but nothing would trig the event. If you have got it running, Oli, I'd be very interested in the solution.


            Sanjay - please post you full script



            • 3. Re: About DxDesigner Automation Script

              I believe you have already checked this out, but just to double-check...

              Have you added below line into your script so as to keep the script running to monitor the event?


              Scripting.DontExit = True

              • 4. Re: About DxDesigner Automation Script

                Hi - for what it's worth, i have this (I get the event handler message box, so I know it's running). I tried a few events, none is triggered....


                GetKeyObjects ()


                Scripting.DontExit = True

                'Gets called on any change in variant


                Dim name,oldname,op


                MsgBox "Event handler started with Scripting DontExit = "& Scripting.DontExit

                Sub Application_OnDataChanged()

                MsgBox "Data Changed"

                End Sub


                Sub Application_OnVariantChanged(Byval name,Byval oldName,Byval op)

                    MsgBox "Application_OnVariantChanged:"& name

                End Sub


                Dim compname, varname

                Sub Application_OnComponentModificationChanged(compName,varName,Op)

                MsgBox "compname : "& compname &"  varname : "&varNAme & " Op : " & op

                End Sub



                Function GetKeyObjects ()


                    Set dxdApp = Application

                    sFileName = dxdApp.GetProjectData.getProjectPath() & "\variant_impex.txt"    


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

                    If vmaddin Is Nothing Then

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

                        vmaddin.Visible = True


                        'MsgBox "vmaddin Is not Nothing"

                        vmaddin.Visible = True

                    End If

                    Scripting.AddTypeLibrary "MGCVARIANTGUI.MGCVariantGUICtrl.1"


                    ' vmaddin.Control.VariantGuiApplication is the VM Application object

                    Set VMApplication = vmaddin.Control.VariantGuiApplication


                    ' VMBOM is the BOM object

                    Set vmbom = vmaddin.Control.VariantGuiApplication.BOM


                    ' vmdoc is the VMDocument object

                    Set vmdoc = vmaddin.Control.VariantGuiApplication.VMDocument


                    VMApplication.VariantMode = Functional


                End Function ' GetKeyObjects   

                • 5. Re: About DxDesigner Automation Script

                  The event sub-routines should be attached to Variant Manager Application, not to DxDesigner Application.

                  So you would need to use Scripting.AttachEvents as below:


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

                  If Not VarManagerAddin Is Nothing Then

                    Scripting.AttachEvents VarManagerAddin.Control.VariantGUIApplication, "varApp"

                  End If


                  Accordingly change the name of the event sub-routines so that they start with the prefix "varApp_" as below:


                  Sub varApp_OnDataChanged()




                  End Sub


                  Sub varApp_OnVariantChanged(...)


                  End Sub





                  Hope the above helps,


                  2 of 2 people found this helpful
                  • 6. Re: About DxDesigner Automation Script

                    Nick - that did the trick, thanks a million !!

                    • 7. Re: About DxDesigner Automation Script

                      Yes, I confirm.

                      It works in case a variant is added, deleted or variant name is changed.