Argo Posted October 30, 2015 Posted October 30, 2015 Hi, I found this lisp by renderman that opens up a DWG. I've employed this with another Lisp to Open up a DWG from excel. However the below code opens up in read only mode. How can i get it to open not in read only mode? (defun c:OpenMyDwg ( / _OpenDwg ) (defun _OpenDwg (dwg readOnly / f oDwg) ;; RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) (vl-load-com) (if (and (setq f (findfile dwg)) (/= 1 (getvar 'sdi))) (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) f (cond ((= T readOnly) :vlax-true) ((:vlax-false))))) (cond (f (prompt "\n** Command not available in SDI mode ** ")) ((prompt (strcat "\n** \"" (strcase (vl-filename-base dwg)) "\" cannot be found ** ")))))) (_OpenDwg "Filepath Directory" T) (princ)) Quote
DuanJinHui Posted October 30, 2015 Posted October 30, 2015 Hi, I found this lisp by renderman that opens up a DWG. I've employed this with another Lisp to Open up a DWG from excel. However the below code opens up in read only mode. How can i get it to open not in read only mode? (defun c:OpenMyDwg ( / _OpenDwg ) (defun _OpenDwg (dwg readOnly / f oDwg) ;; RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) (vl-load-com) (if (and (setq f (findfile dwg)) (/= 1 (getvar 'sdi))) (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) f (cond ((= T readOnly) :vlax-true) ((:vlax-false))))) (cond (f (prompt "\n** Command not available in SDI mode ** ")) ((prompt (strcat "\n** \"" (strcase (vl-filename-base dwg)) "\" cannot be found ** ")))))) (_OpenDwg "Filepath Directory" T) (princ)) Open DWG not in Read Only Mode , Why need use Lisp ? Quote
Argo Posted October 30, 2015 Author Posted October 30, 2015 The script I have sends commands from Excel to CAD but cannot execute commands than require you to enter a file address through the command line. Thus to work around this I want to use a lisp to open the file. Everything works, I can click a button in excel and open up the drawings in CAD but it opens them up in read only mode. Quote
hmsilva Posted October 30, 2015 Posted October 30, 2015 Hi, I found this lisp by renderman that opens up a DWG. I've employed this with another Lisp to Open up a DWG from excel. However the below code opens up in read only mode. How can i get it to open not in read only mode? (defun _OpenDwg (dwg readOnly / f oDwg) ;; RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) Hi Argo, the RenderMan's (BlackBox) '_OpenDwg' function, expects two arguments, the file path and the 'readOnly' flag, T for read only and nil for not read only Henrique Quote
Argo Posted November 2, 2015 Author Posted November 2, 2015 Using nil in the below code (defun c:OpenFile ( / _OpenDwg ) (defun _OpenDwg (dwg readOnly / f oDwg) ;; RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) (vl-load-com) (if (and (setq f (findfile dwg)) (/= 1 (getvar 'sdi))) (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) f (cond ((= T readOnly) :vlax-true) ((:vlax-false))))) (cond (f (prompt "\n** Command not available in SDI mode ** ")) ((prompt (strcat "\n** \"" (strcase (vl-filename-base dwg)) "\" cannot be found ** ")))))) (_OpenDwg "File_path" nil) (princ)) returns the following error ; error: bad function: :vlax-false Quote
satishrajdev Posted November 2, 2015 Posted November 2, 2015 Using nil in the below code (defun c:OpenFile ( / _OpenDwg ) (defun _OpenDwg (dwg readOnly / f oDwg) ;; RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) (vl-load-com) (if (and (setq f (findfile dwg)) (/= 1 (getvar 'sdi))) (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) f (cond ((= T readOnly) :vlax-true) [color="red"]((:vlax-false))[/color]))) (cond (f (prompt "\n** Command not available in SDI mode ** ")) ((prompt (strcat "\n** \"" (strcase (vl-filename-base dwg)) "\" cannot be found ** ")))))) (_OpenDwg "File_path" nil) (princ)) returns the following error ((:vlax-false)) should be (:vlax-false), Highlighted in qouted text (defun c:OpenFile (/ _OpenDwg) (defun _OpenDwg (dwg readOnly / f oDwg) ;; RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) (vl-load-com) (if (and (setq f (findfile dwg)) (/= 1 (getvar 'sdi))) (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) f (cond ((= T readOnly) :vlax-true) (:vlax-false) ) ) ) (cond (f (prompt "\n** Command not available in SDI mode ** ")) ((prompt (strcat "\n** \"" (strcase (vl-filename-base dwg)) "\" cannot be found ** " ) ) ) ) ) ) (_OpenDwg "F:\\123.dwg" nil) (princ) ) Quote
Argo Posted November 2, 2015 Author Posted November 2, 2015 Awesome. That fixes it. Now i just got to get it to not switch back to the other drawing open... Quote
DuanJinHui Posted November 2, 2015 Posted November 2, 2015 Using nil in the below code (defun c:OpenFile ( / _OpenDwg ) (defun _OpenDwg (dwg readOnly / f oDwg) ;; RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) (vl-load-com) (if (and (setq f (findfile dwg)) (/= 1 (getvar 'sdi))) (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) f (cond ((= T readOnly) :vlax-true) ((:vlax-false))))) (cond (f (prompt "\n** Command not available in SDI mode ** ")) ((prompt (strcat "\n** \"" (strcase (vl-filename-base dwg)) "\" cannot be found ** ")))))) (_OpenDwg "File_path" nil) (princ)) returns the following error no test ,you can have a try. (defun c:OpenFile ( / _OpenDwg ) (defun _OpenDwg (dwg readOnly / f oDwg) ;; RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) (vl-load-com) (if (and (setq f (findfile dwg)) (/= 1 (getvar 'sdi)) ) (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) f (cond ((= T readOnly) :vlax-true) ((= nil readOnly) :vlax-false) ) ) ) (cond (f (prompt "\n** Command not available in SDI mode ** ")) ((prompt (strcat "\n** \""(strcase (vl-filename-base dwg))"\" cannot be found ** "))) ) ) ) (_OpenDwg "File_path" nil) (princ) ) Quote
satishrajdev Posted November 2, 2015 Posted November 2, 2015 Awesome. That fixes it. Now i just got to get it to not switch back to the other drawing open... 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.