Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp works in ACAD 2004/05 not in 2006/7

2 REPLIES 2
Reply
Message 1 of 3
BlairmackNZ
156 Views, 2 Replies

Lisp works in ACAD 2004/05 not in 2006/7

Have used this great little routine by Jimmy @ JTBWORLD successfully but it doesn't work in 2006/7 if SDI is 0. Can anyone see a reason for this??

Thanks Blair

;;; SOPEN.LSP
;;; Open command that works for all cases
;;; Works for SDI=0 or SDI=1

;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
;;; 1999-09-12 - First release
;;; 2002-05-14 - Bug fixed
;;; Written for AutoCAD 2000+
;;; Ex: (sopen "c:\\drawing1.dwg")
;;; Note that QAFLAGS might not be restored to 0 so you might want to add (setvar "qaflags" 0) to acaddoc.lsp or any other startup lisp.

;;; opens and activates a file as Read-Only
(defun openRO (fna)
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) fna :VLAX-TRUE))
)

(defun sopen (fna / n)
(if (= 0 (getvar "SDI"))
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) fna))
(progn
(if (not (equal 2 (logand 2 (getvar "qaflags"))))
(setvar "qaflags" (+ (getvar "qaflags") 2))
)
(if (not (equal 4 (logand 4 (getvar "qaflags"))))
(setvar "qaflags" (+ (getvar "qaflags") 4))
)
(command "_.open")
(if (not (equal 0 (getvar "dbmod")))
(command "_y")
)
(command fna)
(setq n 0)
(while (and (< n 4)
(wcmatch (getvar "cmdnames") "*OPEN*")
)
(T
(command "")
)
(setq n (+ n 1))
)
(setvar "qaflags" 0)
)
)
)
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: BlairmackNZ

This work for me in 2006 and 2007.

wrote in message news:5374677@discussion.autodesk.com...
Have used this great little routine by Jimmy @ JTBWORLD successfully but it
doesn't work in 2006/7 if SDI is 0. Can anyone see a reason for this??

Thanks Blair

;;; SOPEN.LSP
;;; Open command that works for all cases
;;; Works for SDI=0 or SDI=1

;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
;;; 1999-09-12 - First release
;;; 2002-05-14 - Bug fixed
;;; Written for AutoCAD 2000+
;;; Ex: (sopen "c:\\drawing1.dwg")
;;; Note that QAFLAGS might not be restored to 0 so you might want to add
(setvar "qaflags" 0) to acaddoc.lsp or any other startup lisp.

;;; opens and activates a file as Read-Only
(defun openRO (fna)
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) fna
:VLAX-TRUE))
)

(defun sopen (fna / n)
(if (= 0 (getvar "SDI"))
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) fna))
(progn
(if (not (equal 2 (logand 2 (getvar "qaflags"))))
(setvar "qaflags" (+ (getvar "qaflags") 2))
)
(if (not (equal 4 (logand 4 (getvar "qaflags"))))
(setvar "qaflags" (+ (getvar "qaflags") 4))
)
(command "_.open")
(if (not (equal 0 (getvar "dbmod")))
(command "_y")
)
(command fna)
(setq n 0)
(while (and (< n 4)
(wcmatch (getvar "cmdnames") "*OPEN*")
)
(T
(command "")
)
(setq n (+ n 1))
)
(setvar "qaflags" 0)
)
)
)
Message 3 of 3
BlairmackNZ
in reply to: BlairmackNZ

I haven't explained myself correctly I think. I have this lisp hardcoded into another lisp routine as below that has worked fine up until 2006. SAP command allows me to save incremental versions of a drawing during the revision process. It's been a great timesaver but as it only works in SDI 1 now it's a real pain in the ####. It means that once I have run the routine I have to manually open the drawing again as the SOPEN does not work.

(defun sopen (fna / ns)
(if (= 0 (getvar "SDI"))
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) fna))
(progn
(if (not (equal 2 (logand 2 (getvar "qaflags"))))
(setvar "qaflags" (+ (getvar "qaflags") 2))
)
(if (not (equal 4 (logand 4 (getvar "qaflags"))))
(setvar "qaflags" (+ (getvar "qaflags") 4))
)
(command "_.open")
(if (not (equal 0 (getvar "dbmod")))
(command "_y")
)
(command fna)
(setq n 0)
(while (and (< n 4)
(wcmatch (getvar "cmdnames") "*OPEN*")
)
(T
(command "")
)
(setq n (+ n 1))
)
(setvar "qaflags" 0)
)
)
(princ)
)
;;=======================================================
(defun c:sap (/ count sflag)
;;
(setq count 1)
(setq name (STRCAT (getvar "dwgprefix")(getvar "dwgname")))
(setq namelen (- (strlen name) 4))
(setq newname (strcat (strcase (substr name 1 namelen)) "-old"))
;;
(while (/= sflag 1)
;;check if file exists - if so do nothing - if not write block out
(if (not (findfile (setq newname-rev (strcat newname (itoa count) ".DWG"))))
(progn
(command "saveas" "" newname-rev)
(command "close")
(setq sflag 1)
);progn
(setq count (1+ count))
);if
);while
(sopen name)
(princ)
)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost