5 Replies Latest reply on Nov 17, 2011 11:56 AM by Jeremy Schmidt

    check in from SolidWorks

    Jeremy Schmidt

      I'm trying to have SolidWorks documents auto check in on the initial save.  I'm not seeing any options for this.  I know that this can be done with Dispatch, but it doesn't seem to have the capability to interface with SolidWorks and errors out if the document is open in SolidWorks.  Are there any other options I'm not thinking of?


      Does anyone know how to check in a document from within SolidWorks using the API (either SW or EPDM)?  I know it can be done through the SolidWorks interface, but I can't find a way to do it programmatically.  I'm not finding any SolidWorks APIs for EPDM.  I can't check it in from EPDM as the admin even if the warning "The file is open in another application." is unchecked.  I know how to close the file, check it in, check it out, and open it back up again programmatically, but I'd rather not if I don't have to.  Some files could be quite large and this process would be very time consuming.


      Any ideas?

        • Re: check in from SolidWorks
          Jeremy Schmidt

          Does anyone have any thoughts on this?


          I tried setting the read-only file attribute to enabled, checking in the file, checking out the file, and then resetting the read-only attribute back to disabled.  This doesn't work because SW and EPDM still consider the file in use when the read-only attribute is enabled, so the file can't be check in or out.


          I find it hard to believe that this can't be done, because it's easily possible to do it manually through the user interface.  You just save the document in the vault.  Right click on the file in the SW tree and choose check in and then either enable to keep checked out flag or check out the file afterwards.


          Am I thinking about this all wrong?  Is there an easier way to do this.  All I want is for a new file to be automatically checked in when it's saved from SW.

          • Re: check in from SolidWorks
            Russell Saari



            Use the API_GB.chm(API Help Booklet for EPDM) in the EPDM folder in program files ****NOT MANY PEOPLE KNOW THIS****. It comes with EPDM automatically just in kind of a weird location. And for what you are trying to do use solidworks SaveAs3 Method(Saves the Drawing), use the vault login then use the EPDM IEdmFile5 Interface and specifically the UnlockFile method(Checks In File). Hope this helps here is a sample of how to do it in C#



                           using SolidWorks.Interop.sldworks; //Solidworks Reference

                           using SolidWorks.Interop.swconst; //Solidworks Constant Reference            

                           using EdmLib; //PDM Library


                           longstatus = swDoc.SaveAs3("File Location and File Name", 0, 4); //4 saves all files references


                           //Create a file vault interface and log in to a vault.

                            EdmVault5 vault = default(EdmVault5);

                            vault = new EdmVault5();

                            vault.LoginAuto("Engineering", 0);


                            //Get the vault's root folder interface.

                            IEdmFile5 file = default(IEdmFile5);

                            IEdmFolder5 folder = default(IEdmFolder5);

                            folder = vault.RootFolder;


                            //Check in FIle

                            file = vault.GetFileFromPath("file location", out folder); //Get File

                            file.UnlockFile(0, "Checked In By Me", 8, null); //Check In File

                            file.ChangeState("Check ENG Design", folder.ID, "Created By Me", 0, 0); //Change State