3 Replies Latest reply on Aug 11, 2017 12:45 AM by ozaouiidrissi

    Variant Manager Automation with VBscript

    ozaouiidrissi

      Hi community,

       

      i need to open Variant manager and select "create variant / Function Schematics" field (below screenshot) using VBscript automation,

       

      Capture.PNG

      someone can help me  ?

       

      BR,

        • 1. Re: Variant Manager Automation with VBscript
          juergen.dickler

          Hi

          Not necassary to open VM first but if you will do:

           

            Set DXDApp = GetObject(, "viewdraw.Application")

            Set VMaddin = DXDApp.AddIns("Variant Manager")

             If VMaddin Is Nothing Then

              invokeVM

             Else

              VMaddin.visible = True

              Set VMaddin = Nothing

             End If

           

          set to variant view:

            Set DXDApp = GetObject(, "viewdraw.Application")

            Set VMaddin = DXDApp.AddIns("Variant Manager")

            erg = VMaddin.Control.VariantGuiApplication.Application.GenerateVariantView("MyVariant")

           

          reset to Master view:

            Set DXDApp = GetObject(, "viewdraw.Application")

            Set VMaddin = DXDApp.AddIns("Variant Manager")

            erg = VMaddin.Control.VariantGuiApplication.Application.ResetView

          • 2. Re: Variant Manager Automation with VBscript
            Patrick.Cashman

            Here is a complete script, with the key function, PutVariant:

             

            Sub create_variant()

                     Dim dxapp

                     Dim vmdoc

                     Dim vmapp

                     Dim AddinObj

             

                     dxapp = GetObject(, "ViewDraw.Application")

                     AddinObj = dxapp.Addins("Variant Manager")

                     vmapp = AddinObj.Control.VariantGUIApplication

                     vmdoc = vmapp.VMDocument

                     vmdoc.PutVariant("my_variant_name", "my_variant_number", "variant_description")

                     vmapp.Save()

             

            End Sub

            You may need to add some error traps to check if your dxapp, vmapp, and vmdoc are valid before you use them, but this is the basics of it. You may also want to set those variables to Nothing when the script is done, so you don't leave them hanging open.