Jump to content

Open DWG not in Read Only Mode Lisp


Argo

Recommended Posts

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))

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...