2 Replies Latest reply on Jan 5, 2017 6:56 PM by Nicholas Nadeau

    PackAndGo issues with Com library

    Alex Steinberg

      Hi there,

       

      I’m currently working on what should have been a quick project that manages our internal file releases, and I’m trying to use the pack and go interface through COM. I’ve written a small python wrapper to the com interface, and am just running into my first major roadblock. Basically when I run the IModelDoc2.Extension.GetPackandGo function I get an error thrown out that says “ Parameter not Optional” and I can’t seem to get around this. It seems to me from the online help that the only parameter going into this function is the modeldoc extension that is passed in by the fact that get pack and go is a member function of the interface. Is there something I’m missing? The code shown below is a quick snippet that shows the problem. It is python code, but I hope the comments help illustrate the problem.  The output is shown just below the code in a light blue. Below that is the code that is generated by the python com library that I am using to wrap the interface. So clearly it’s COM parser is showing no other variables necessary for working.

       

       

      '''

      Created on Oct 31, 2013

       

      @author: Alex Steinberg

      '''

      import win32com.client as win32

      import os

      win32.gencache.EnsureModule('{83A33D31-27C5-11CE-BFD4-00400513BB57}',0,21,0) #SldWorks Type Library

      win32.gencache.EnsureModule('{4687F359-55D0-4CD3-B6CF-2EB42C11F989}',0,21,0) #Constants

      app = win32.dynamic.Dispatch('SldWorks.Application') #Late bind the COM interface

      app.Visible = True #Set the visibility of the window

      filename = "Test Assembly.SLDASM" #Define relative path

      asm = app.OpenDoc(os.path.abspath(filename), win32.constants.swDocASSEMBLY) #Attempt to open the assembly

      app.ActivateDoc(filename) #Activate the assembly

      png = asm.Extension.GetPackAndGo() # Attempt to retrieve the associated pack and go interface.

       

      Result

          png = asm.Extension.GetPackAndGo() # Attempt to retrieve the associated pack and go interface.

        File "<COMObject <unknown>>", line 2, in GetPackAndGo

      1. pywintypes.com_error: (-2147352561, 'Parameter not optional.', None, None)