Aftertouch Posted May 12, 2021 Posted May 12, 2021 (edited) Hello all, I got a problem, wich i think many others will have also. Our company is fully running on Teams now, including all CAD-files. We use Team/Sharepoint, with the SYNC tool to acces our DWG files from the 'Windows Explorer'. But when i open a DWG, and a colleague opens the same file, the READ-ONLY doesnt seem to work... This results in double DWG files with different content. I am looking for a way to fix this, and im very close... I managed to detect a already open DWG: (if (findfile (strcat (getvar "dwgprefix")(vl-filename-base (getvar "dwgname")) ".dwl")) (progn (if (wcmatch (strcase (getvar "LOGINNAME")) (strcase (read-line (open (strcat (getvar "dwgprefix")(vl-filename-base (getvar "dwgname")) ".dwl") "r")))) (progn ;(alert "OPEN YOURSELF") ) (progn (alert "ALREADY OPENED BY ANOTHER PERSON") (LOAD "ONEDRIVE_READONLY_REACTOR.LSP")) ) ) ) (progn ;(alert "FIRST OPEN, NO PROBLEM") ) ) Code above detects usage, based on the DWL file, and when already in use, shows a messages and runs the LSP: ONEDRIVE_READONLY_REACTOR, as shows below. ;;--------------------------------------------;; ;;--------------------------------------------;; (if (not ONEDRIVEREADONLY) (setq ONEDRIVEREADONLY (vlr-command-reactor nil '((:vlr-commandwillstart . LOCKSAVEMODE)))) ) ;;--------------------------------------------;; ;;--------------------------------------------;; (defun LOCKSAVEMODE (rea lst / doc layNme ucsNme) (if (vl-position (car lst)'("SAVE" "QSAVE" "SAVEAS")) (progn (alert "PLEASE DONT SAVE!") ) ) ) ;;--------------------------------------------;; ;;--------------------------------------------;; (princ) ;;--------------------------------------------;; ;;--------------------------------------------;; This activates a REACTOR, that detects any saving-action, and shows another message when a save command is triggerd. This will still cause a new DWG file, but the user has been warned. What i would like, is to be able to DISABLE the save commands totaly. But when i use 'UNDEFINE' is defines for AutoCAD in total, not just the DWG file. Any suggestions how to block saving actions? Force to open as READONLY just seems not possible, since the LSP is triggered after opening the file. Edited May 12, 2021 by Aftertouch Quote
rkmcswain Posted May 14, 2021 Posted May 14, 2021 Quote We use Team/Sharepoint, with the SYNC tool to acces our DWG files from the 'Windows Explorer'. Is that your only option? What benefits are you gaining from this setup, and is it outweighing the double save issue? Could you possibly look at another solution such as Egnyte? I'm not sure how good of a lisp based solution is going to be. Quote
LaneH Posted August 3, 2023 Posted August 3, 2023 Aftertouch, did you ever come up with a viable solution to this one? Quote
Aftertouch Posted August 3, 2023 Author Posted August 3, 2023 @LaneH yes and no.. I got a solution working, wich creates a text file and where a reactor check for existance of the file.sworks for all open and save funtions. But mallfunctions with a fatal error... Quote
BIGAL Posted August 4, 2023 Posted August 4, 2023 It would be better to stop at the dwg is open already and get the user name of who has it open. Send a message to that person or yell across the room. Quote
LaneH Posted October 17, 2023 Posted October 17, 2023 @Aftertouch, below is a working solution that I've come up with. It creates and deletes .dwl3 files the same way that AutoCAD handles .dwl and .dwl2 files. It also checks for a .dwl3 file each time you open a drawing and will warn you if someone else has it open, forcing you to close. Hope you find it useful! My acaddoc.lsp contains the following: (load "H:\\CAD\\C3D\\LSP\\dwl3.lsp") and dwl3.lsp looks like this: ;;----- Popup - Lee Mac --------------------------------- ;; A wrapper for the WSH popup method to display a message box prompting the user. ;; ttl - [str] Text to be displayed in the pop-up title bar ;; msg - [str] Text content of the message box ;; bit - [int] Bit-coded integer indicating icon & button appearance ;; Returns: [int] Integer indicating the button pressed to exit (defun LM:popup ( ttl msg bit / wsh rtn ) (if (setq wsh (vlax-create-object "wscript.shell")) (progn (setq rtn (vl-catch-all-apply 'vlax-invoke-method (list wsh 'popup msg 0 ttl bit))) (vlax-release-object wsh) (if (not (vl-catch-all-error-p rtn)) rtn) ) ) ) ;;----- Read DWL3 ----------------------------------------- (defun c:readdwl3file () (setq dwl (strcat (getvar "Dwgprefix") (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4)) ".dwl3")) (setq file (findfile dwl)) (if file (progn (setq data "") (setq file (open dwl "r")) (if file (setq data (read-line file)) ) (close file) (if data (setq data (strcase (vl-string-trim " " data))) (setq data "none") ) ) (setq data "none") ) data ) ;;----- Write DWL3 ---------------------------------------- (defun c:writedwl3file () (setq user (getvar "loginname")) (setq dwg (strcat (getvar "Dwgprefix") (getvar "dwgname"))) (setq dwl (strcat (getvar "Dwgprefix") (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4)) ".dwl3")) (setq dwlowner (c:readdwl3file)) (if (null dwlowner) (setq dwlowner "unknown") ) (if (not (findfile dwl)) (progn (if (setq des (open dwl "w")) (progn (write-line user des) (close des) ) (princ "") ) ) (and (saveclosereactor) (and (LM:popup "AutoCAD Alert" (strcat dwg " is currently in use by " dwlowner ". Please open the file read-only.") (+ 0 16 4096)) (command "close" "No"))) ) ) ;;----- Delete DWL3 --------------------------------------- (defun c:deletedwl3file () (setq dwl (strcat (getvar "Dwgprefix")(substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4)) ".dwl3")) ; Excluded the extension from dwgname (if (findfile dwl) (vl-file-delete dwl) ) (princ) ) ;;----- SaveClose Reator - Lee Mac (Modified) ----------------- (defun SaveCloseReactor nil (vl-load-com) ( (lambda ( data / react ) (if (setq react (vl-some (function (lambda ( reactor ) (if (eq data (vlr-data reactor)) reactor) ) ) (cdar (vlr-reactors :vlr-editor-reactor) ) ) ) (if react (if (vlr-added-p react) (vlr-remove react) (vlr-add react) ) ) (setq react (vlr-editor-reactor data (list (cons :vlr-beginclose 'CustomCloseCallBack) (cons :vlr-savecomplete 'CustomSaveCallBack) ) ) ) ) (setq *error* nil) ; Suppress any potential error messages (if (vlr-added-p react) (setq status "SaveClose reactor is on") (setq status "SaveClose reactor is off") ) ) "SaveClose-Reactor" ) ) (defun CustomCloseCallBack (reactor arguments) (if (= (getvar "WRITESTAT") 1) (c:deletedwl3file) ) ; Deletes .dwl3 file when closing or quitting a read-write file (vlr-remove reactor) ; Ensure the reactor is removed after it's triggered ) (defun CustomSaveCallBack (reactor arguments) (and (c:deletedwl3file) (c:writedwl3file)) ; Saves a new .dwl3 when saving ) ;;----------------------------------------------------------- (saveclosereactor) (if (= (getvar "WRITESTAT") 1) (c:writedwl3file) ) ; Writes .dwl3 file when opening a read-write file 2 Quote
Aftertouch Posted October 18, 2023 Author Posted October 18, 2023 @LaneH, Thanks for the code! My code uses a 'vlr-commandended' function, to check all type of close/dave command's. Works, but the code is not very clean... Your reactor is much better and seems to work very smooth. Quote
LaneH Posted October 18, 2023 Posted October 18, 2023 @Aftertouch, happy to share! I can't believe the issue hasn't been resolved by Microsoft or Autodesk, but I'm thrilled to have a solution. Gotta give credit to @Lee Mac for getting me started in the right direction on the reactor. Works like magic! Quote
Aftertouch Posted October 18, 2023 Author Posted October 18, 2023 @LaneH Microsoft wont fix this, sjnce the lock on the DWL is a Autodesk problem. Autodesk wont fix this, since they wanna sell the Construction Cloud and say its a Microsoft problem. 1 Quote
Myles - Thinkscape Posted October 22, 2023 Posted October 22, 2023 We've solved this issue for SharePoint Online/Teams and AutoCAD DWG document locking with our drive mapping tool Zee Drive. Zee Drive automatically takes out a lock on the DWG file, preventing other users from editing the same file. Quote
Aftertouch Posted October 23, 2023 Author Posted October 23, 2023 @LaneH, unfortunately your solution has the same issues as mine had. Sometimes it gives error for not handling 'templates' properly or doesnt always remove the files when open/save/close is performed to quickly... Damn OneDrive... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.