1 Reply Latest reply on Jan 4, 2017 4:05 AM by Simon Turner

    Having trouble with GetFileCopy method

    Mike Bosscher

      I'm working on implementing design checker as part of a workflow transition. I've gotten nearly all the bugs out, but the one outstanding issue is that the task will not update the version of the design check file (.swstd) on the task host. We're planning on increasing the number of checks we're doing over time (our users need a bit of time to adjust..), so I need to ensure that the task host has the current version of the design checker file each time it runs the task.

       

      I'm a little surprised that the design check task doesn't already do this, but have been assured by our VAR that solidworks is aware of the issue and working towards a resolution in a later release. Unfortunately, I don't have time to wait for that release, so I'd like to add the necessary code to the task script. My understanding is that the GetFileCopy method would be appropriate, but I can't seem to figure out how it works. Can someone step me through how to use it in VBA?

       

      What I've got to date looks something like this;

      ...

      ...

      ...

      Call LoginToVault (this is found in the default design checker task script, the following is what I've added, based on a couple examples I found here in the forum, and the API help files)

       

      Call GetFileCopy(Me.Handle.ToInt32(),0,0,EdmGetFlag.EdmGet_Simple,"")

      ...

      ...

      ...

      Private Sub GetFileCopy( _
      Dim lParentWnd As System.Integer, _
      Dim poVersionNoOrRevisionName As System.Object, _
      Dim poPathOrFolderID As System.Object, _
      Dim lEdmGetFlags As System.Integer, _
      Dim bsNewName As System.String _
      )

      Dim SWSTDFolder as IEdmFolder5
      Dim GetSWSTD as IEdmFile5

      set SWSTDFolder = vault.GetFolderFromPath("C:\Vault_Sandbox\Tigercat\Support\SolidWorks\2015\DesignCheckerFiles")
      GetSWSTD = SWSTDFolder.GetFile("Released.swstd")
      GetSWSTD.GetFileCopy(lParentWnd,poVersionNoOrRevisionName,poPathOrFolderID,lEdmGetFlags,bsNewName)

      End Sub

       

      Any suggestions would be appreciated.

      Mike.

        • Re: Having trouble with GetFileCopy method
          Simon Turner

          Don't pass anything in for the bsNewName argument - you would only use that for changing the name of the file.

          Also, if this is VBA or VBScript, you need to Set GetSWSTD = ...

          If it is .Net, then you don't need Set on the previous line.

           

          Assuming it is VBA/VBScript:

          Set SWSTDFolder = vault.GetFolderFromPath("C:\Vault_Sandbox\Tigercat\Support\SolidWorks\2015\DesignCheckerFiles")

          Set GetSWSTD = SWSTDFolder.GetFile("Released.swstd")

          GetSWSTD.GetFileCopy 0, 0, , EdmGet_Simple

           

          Otherwise:

          SWSTDFolder = vault.GetFolderFromPath("C:\Vault_Sandbox\Tigercat\Support\SolidWorks\2015\DesignCheckerFiles")

          GetSWSTD = SWSTDFolder.GetFile("Released.swstd")

          GetSWSTD.GetFileCopy(0, 0, , EdmGetFlag.EdmGet_Simple)