5 Replies Latest reply on Oct 16, 2017 1:01 PM by Jacob Corder

    PDM PostLock/PreUnlock Read Only During Callback

    Matt McCormick

      During the callbacks for PostLock and PreUnlock, if a file is checked in or out using the PDM Add-in for Solidworks, the file is always in read-only status and cannot be modified. However, when checking in or out through explorer and opening the file, the file is not read-only and can be modified. I would like to make modifications to a file during the check out process and save it (locally) which cannot be completed due to the file being read-only, and I would also like to make modifications to a file during the check in process and save it which also cannot be completed due to the file being read-only. Is there a way around this issue, other than restricting users to only being able to check in from explorer?

        • Re: PDM PostLock/PreUnlock Read Only During Callback
          Jacob Corder

          does the person have the file open in solidworks or another program?

           

          if so then its readonly because the file is open by another process.

           

          the way around this is to have an addin inside of solidworks that does the work.

           

          what exactly are you trying to update on these state changes?  it matters what to determine the best method for making this work for you

            • Re: PDM PostLock/PreUnlock Read Only During Callback
              Matt McCormick

              I am examining two situations:

              • The user has the file open in solidworks (and not any other application), and using the "SOLIDWORKS PDM Client" solidworks add-in to check-in/check-out the file, which triggers the PDM PostLock/PreUnlock callback in my custom PDM add-in.
                • The file is read-only and cannot be modified
              • The user does not have the file open in solidworks (or any other application), and uses the right click check-in/check-out functionality of PDM Pro in windows explorer, which triggers the PDM PostLock/PreUnlock callback in my custom PDM add-in. In this case, as part of the PostLock/PreUnlock callback (Before check-in, and after check-out), I open the file in solidworks, make modifications, save the file, then allow the check-in or check-out process to complete (or abort check-in if need be), all through the api.
                • The file is not read-only, and can be opened in solidworks, modified, saved, and closed.

              The read-only state is not due to the fact that the file is open in Solidworks or another application; It is how PDM handles preventing modification to files which are in a checked-in state.

              Specifically, I am modifying revision block and revision information, custom properties, and performing data validation/formatting. Regardless of what I am attempting to accomplish, I don't see why the functionality differs between the two methods or how it is beneficial.

              Potentially worthy of note is that I can debug both situations and trigger breakpoints if any diagnostic information would be useful.

                • Re: PDM PostLock/PreUnlock Read Only During Callback
                  Jacob Corder

                  Your issue is because it IS locked by solidworks. How are you setting the revision block without opening the file? Opening the file invisible?

                   

                  Can't do that if it's open by solidworks already.

                   

                  If you are doing this. Attach to the solidworks instance and run your code using that instance of solidworks. Use process.getrunningprocesses and find the solidworks one that has the file open.

                   

                   

                  This should solve your problem. I know because I have done this.

                    • Re: PDM PostLock/PreUnlock Read Only During Callback
                      Matt McCormick

                      In the situation where I am using the "SOLIDWORKS PDM Client" add-in to check in the file, the file is already open in solidworks. Upon clicking check in and accepting check-in dialog box, solidworks makes the file read-only, then triggers the Pre-Unlock callback during which my code runs. After my code completes running, the Pre-Unlock callback exits and allows the check-in process to complete.

                       

                      The file is not "locked" (checked in state) by PDM, but is "locked" (made read-only) by solidworks, which is the crux of the issue, due to it only occuring in this case and not in the other. I do not need to find the process which has the file open, because I can use the vault object handed to you by the Pre-Unlock callback.