open drawing and continue the command in lisp

open drawing and continue the command in lisp

Anonymous
Not applicable
1,326 Views
5 Replies
Message 1 of 6

open drawing and continue the command in lisp

Anonymous
Not applicable

my lisp here:

(defun c:open11()

;; open dwg files
(vl-load-com)
(setq cnt 0)
(setq alls '(
"44207.dwg"
)
)

(setq n (length alls))
(repeat n
(setq file (nth cnt alls))
(setq openfile (strcat "e:\\testing\\" file))
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) openfile))
(command "model")
(setq EMIN (getvar "EXTMIN") )
(setq EMAX (getvar "EXTMAX") )
(setq MINPT (list (car EMIN) (cadr EMIN) ) )
(setq MAXPT (list (car EMAX) (cadr EMAX) ) )
(command "rectangle" minpt maxpt)
(setq dname (getvar "dwgname") )
(setq dpath (getvar "dwgprefix") )
(setq newfile (strcat dpath (substr dname 1 (- (strlen file) 4 ) ) "_blk.dwg") )
(command "close")

(setq cnt (1+ cnt))

)
)

 

 

when opened the dwg, then the lisp stopped. How to continue running the follows lisp command?

0 Likes
1,327 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

As far as I know, a Lisp routine cannot "survive" the move from one drawing into another, but can work only in the drawing in which it is begun.  I haven't tried other ways to achieve the same thing, but I believe the issue has been raised here before [e.g. some such things may be achievable using Scripts] -- try Searching.  But looks like what you have should be doable from within one drawing, by way of Inserting your 'openfile' drawing into the current one, drawing your rectangle around the bounding box of that, and Wblocking that rectangle out to the new drawing with '_blk' at the end of its name, then Erasing and Purging the 'openfile' Block.

Kent Cooper, AIA
Message 3 of 6

Anonymous
Not applicable

I'm try use script working for "open and woking somethings" and I want to delete  script file after finish work.

Can you help me about that.

Thank you.

0 Likes
Message 4 of 6

ronjonp
Mentor
Mentor

If all you want to do is delete the script file then: (vl-file-delete "fullpathtofile")

0 Likes
Message 5 of 6

Sea-Haven
Mentor
Mentor

I am trying to remember as this was set up for a server with std dwg's it may do what you want.

 

(defun openblk (blkname / adocs)
(setq acDocs (vla-get-documents (vlax-get-acad-object)))
(vla-open acDocs blkname)
(vla-activate (vla-item acdocs 1))
;(vla-put-activedocument (vlax-get-acad-object) (vla-item acdocs 1))
)

 

0 Likes
Message 6 of 6

Anonymous
Not applicable

Thank you about your suggestion, but my action is use a lisp program load a script file. The Script has functions open a drawing to do some thing follow coded, after that is close  the drawing, so the code line using delete script file in lisp program not available.

0 Likes