JPlanera Posted December 13, 2011 Posted December 13, 2011 Is there a way to return the current, open drawing file path?? Quote
JPlanera Posted December 13, 2011 Author Posted December 13, 2011 Excellent! Thank you, kind sir. Quote
alanjt Posted December 13, 2011 Posted December 13, 2011 You're welcome. Also, the following will return the active drawing name: (getvar 'DWGNAME) Quote
JPlanera Posted December 13, 2011 Author Posted December 13, 2011 Perfect. I was messing around with that and figured out that i can use (STRCAT ) to combine the two, but i am having a hard time opening the file. I am using: (setq CD (getvar 'dwgprefix) CN (getvar 'dwgname) CF (strcat CD CN)) (open CF "w") I did a save as before this routine and i tested that "CF" is still active, however, i can not get it to open. Is there an error in my code? Quote
alanjt Posted December 13, 2011 Posted December 13, 2011 Perfect. I was messing around with that and figured out that i can use (STRCAT ) to combine the two, but i am having a hard time opening the file. I am using: (setq CD (getvar 'dwgprefix) CN (getvar 'dwgname) CF (strcat CD CN)) (open CF "w") I did a save as before this routine and i tested that "CF" is still active, however, i can not get it to open. Is there an error in my code? OPEN doesn't work like that. It's for reading the contents of text files (read through the developer's HELP). Plus, why would you open a drawing you already have open? Quote
JPlanera Posted December 13, 2011 Author Posted December 13, 2011 Hmmm.. Ok.. I am running a routine that saves the current drawing to an archive folder, renames it and does some "stuff" to it. At the end of the routine I want to open the original file back up. Quote
alanjt Posted December 13, 2011 Posted December 13, 2011 Hmmm.. Ok.. I am running a routine that saves the current drawing to an archive folder, renames it and does some "stuff" to it. At the end of the routine I want to open the original file back up. You'll need a bit of VLISP: (vla-activate (vla-open (vla-get-activedocument (vlax-get-acad-object)) <FileName&Path> <Readonly>)) ;; For readonly argument, feed it :vlax-false or :vlax-true (true for readonly) Quote
JPlanera Posted December 13, 2011 Author Posted December 13, 2011 You'll need a bit of VLISP: (vla-activate (vla-open (vla-get-activedocument (vlax-get-acad-object)) <FileName&Path> <Readonly>)) ;; For readonly argument, feed it :vlax-false or :vlax-true (true for readonly) Can be my created list "CF"? Quote
alanjt Posted December 13, 2011 Posted December 13, 2011 Can be my created list "CF"? Yes. As long as it find a valid file path, it'll open it. This subroutine should give you what you want... (defun _open (file&path) (if (setq file&path (findfile file&path)) (not (vl-catch-all-error-p (vl-catch-all-apply '(lambda (/) (vla-activate (vla-open (vla-get-activedocument (vlax-get-acad-object)) file&path :vlax-false) ) ) ) ) ) ) ) (_open cf) Quote
JPlanera Posted December 13, 2011 Author Posted December 13, 2011 Thanks a lot. Ill give it a go and let you know if I have a problem! Geez, something as simple as opening a file can be so involved.. Quote
alanjt Posted December 13, 2011 Posted December 13, 2011 Thanks a lot. Ill give it a go and let you know if I have a problem! Geez, something as simple as opening a file can be so involved.. Give a shout if you need more help. Quote
JPlanera Posted December 14, 2011 Author Posted December 14, 2011 Give a shout if you need more help. Ok, I tried to add your routine to my existing program without the sub-routine. Maybe there is another way to go about this, but the result of this LISP is to SAVE the current drawing to another folder, bind all xrefs, and reopen the original drawing but i want the "ARCHIVED" drawing to be the current, active document in order to verify the bound xrefs as per the 'alert' in the lisp... It is not working. Take a look and see what can be improved/modified... I appreciate your help. (DEFUN C:ARCHIVER (/ FN CD CN CF AD AN AF) (setq FN (getfiled "Save Archive As" "" "dwg" 1)) (if (= FN nil ) (progn (princ)(princ "...ARCHIVER ABORTED...")(princ)) (progn (setvar "cmdecho" 0) (setq CD (getvar 'DWGPREFIX) CN (getvar 'DWGNAME) CF (strcat CD CN)) (command "-xref" "r" "*" "" "qsave" "saveas" "" FN "y" "-xref" "b" "*" "" "zoom" "e" "-purge" "all" "*" "N" "QSAVE") (setq AD (getvar 'DWGPREFIX) AN (getvar 'DWGNAME) AF (strcat AD AN)) (vl-load-com) (if (setq CF (findfile CF)) (not (vl-catch-all-error-p (vl-catch-all-apply '(lambda (/) (vla-activate (vla-open (vla-get-activedocument (vlax-get-acad-object)) CF :vlax-false) ) ) ) ) ) ) (if (setq AF (findfile AF)) (not (vl-catch-all-error-p (vl-catch-all-apply '(lambda (/) (vla-activate (vla-open (vla-get-activedocument (vlax-get-acad-object)) AF :vlax-false) ) ) ) ) ) ) (setvar "cmdecho" 1) (alert "MAKE SURE ALL XREFS HAVE BEEN BOUND.\nTYPE XREF AT THE COMMAND LINE.") (princ) ))) Let it be known that I am teaching myself how to code, so forgive me if it is done "the hard way"... :-) 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.