stephen.coff
2008-06-24, 08:43 AM
Guys,
It has been some time since i have played with a lisp routine. Really not up to scratch and maybe a much better way of doing what i wish outside of Lisp, open to any suggestions what so ever.
I have our drawings structured in a particular way so things should never changed and the way i wish to approach this should cause any dramas at my end. I just don't know how to fully complete the task with Lisp and this is where i require some assistance.
I usually etransmitt files when i send them though i seem to be getting more and more people asking for them as a bound file lately. I wanted to write a small routine to bind the files though also place them in another folder and keep the original not bound.
I need to run the routine on the open file and have it save the file to a new location (two folders deeper "/outgoing/080624/"). I seem to have this part sorted though get stuck when it comes to binding of that saved file. Because the routine save a copy to the required location though i want this new copy to be bound and not the original. That is where i get stuck and hope i have explained myself enough?
Here is what i have so far, haven't looked over it in detail and expect errors.
How do i have the routine close the original file and then continue with the new file?
(defun c:bind (/ dp dn cd Outgoingpath datepath newpath savepath *blks* ref xname)
(vl-load-com)
(setvar "cmdecho" 1)
(setvar "filedia" 0)
(setq dp (getvar "dwgprefix"))
(setq dn (vl-filename-base (getvar "dwgname")))
(setq cd (strcat (getvar "dwgprefix") (getvar "dwgname")))
(setq Outgoingpath (strcat (getvar "dwgprefix") "Outgoing\\"))
(vl-mkdir Outgoingpath)
(setq
datepath (strcat (menucmd "M=$(edtime,$(getvar,date),YYMODD)")
"\\"
)
)
(setq newpath (strcat outgoingpath datepath))
(vl-mkdir newpath)
(setq savepath (strcat newpath dn))
(command "save" savepath "")
(command "open" savepath "")
(command "-layer" "Unlock" "*" "")
(setq *blks*
(vla-get-Blocks
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
)
(vlax-for item *blks*
(if (eq (vla-get-IsXref item) :vlax-true)
(progn
(setq ref (tblsearch "BLOCK" (setq xname (vla-get-Name item))))
(if (eq (logand (cdr (assoc 70 ref)) 32) 32)
(command "-xref" "_B" xname)
(command "-xref" "_D" xname)
)
)
)
)
(princ "...ALL XREF'S BOUND & ALL UNREFERENCED XREF'S REMOVED...")
(setvar "tilemode" 0)
(command "zoom" "extents")
(command "-layer" "lock" "*" "")
(command "purge" "a" "*" "n")
(command "audit" "y")
(setvar "filedia" 1)
(command "save" "y")
(command "close" "n")
)
Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)
It has been some time since i have played with a lisp routine. Really not up to scratch and maybe a much better way of doing what i wish outside of Lisp, open to any suggestions what so ever.
I have our drawings structured in a particular way so things should never changed and the way i wish to approach this should cause any dramas at my end. I just don't know how to fully complete the task with Lisp and this is where i require some assistance.
I usually etransmitt files when i send them though i seem to be getting more and more people asking for them as a bound file lately. I wanted to write a small routine to bind the files though also place them in another folder and keep the original not bound.
I need to run the routine on the open file and have it save the file to a new location (two folders deeper "/outgoing/080624/"). I seem to have this part sorted though get stuck when it comes to binding of that saved file. Because the routine save a copy to the required location though i want this new copy to be bound and not the original. That is where i get stuck and hope i have explained myself enough?
Here is what i have so far, haven't looked over it in detail and expect errors.
How do i have the routine close the original file and then continue with the new file?
(defun c:bind (/ dp dn cd Outgoingpath datepath newpath savepath *blks* ref xname)
(vl-load-com)
(setvar "cmdecho" 1)
(setvar "filedia" 0)
(setq dp (getvar "dwgprefix"))
(setq dn (vl-filename-base (getvar "dwgname")))
(setq cd (strcat (getvar "dwgprefix") (getvar "dwgname")))
(setq Outgoingpath (strcat (getvar "dwgprefix") "Outgoing\\"))
(vl-mkdir Outgoingpath)
(setq
datepath (strcat (menucmd "M=$(edtime,$(getvar,date),YYMODD)")
"\\"
)
)
(setq newpath (strcat outgoingpath datepath))
(vl-mkdir newpath)
(setq savepath (strcat newpath dn))
(command "save" savepath "")
(command "open" savepath "")
(command "-layer" "Unlock" "*" "")
(setq *blks*
(vla-get-Blocks
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
)
(vlax-for item *blks*
(if (eq (vla-get-IsXref item) :vlax-true)
(progn
(setq ref (tblsearch "BLOCK" (setq xname (vla-get-Name item))))
(if (eq (logand (cdr (assoc 70 ref)) 32) 32)
(command "-xref" "_B" xname)
(command "-xref" "_D" xname)
)
)
)
)
(princ "...ALL XREF'S BOUND & ALL UNREFERENCED XREF'S REMOVED...")
(setvar "tilemode" 0)
(command "zoom" "extents")
(command "-layer" "lock" "*" "")
(command "purge" "a" "*" "n")
(command "audit" "y")
(setvar "filedia" 1)
(command "save" "y")
(command "close" "n")
)
Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)