mikko.sallinen
2008-03-17, 10:11 AM
Hi,
I have plenty of engineering diagrams in model space in same dwg. Diagrams are located from left (0,0) to right between 500 and from up to down between 300.
Quantity of vertical diagrams varies. In all there is up to 80 diagrams in same drawing.
Just finished "matrix" plot program, which plots 300x500 area by given matrix, e.g.
command pplot 1,1, plots 300x500 area, upper right corner for plotting is 0,0
command pplot 2,1, plots 300x500 area, upper right corner for plotting is 500,0
command pplot 3,2, plots 300x500 area, upper right corner for plotting is 1000, 300
This matrix plot saves me to make boring manual plot after plot.
Now I would like to plot all diagrams using one command, so I need to test if block exists for example coordinates 2,2.
If block exists in coordinates plot 300x500 area. Upper right corner for plotting is 500,300.
I havent done this kind of "if block exists program" before, so your professional help would be needed.
ccowgill
2008-03-17, 12:39 PM
Hi,
I have plenty of engineering diagrams in model space in same dwg. Diagrams are located from left (0,0) to right between 500 and from up to down between 300.
Quantity of vertical diagrams varies. In all there is up to 80 diagrams in same drawing.
Just finished "matrix" plot program, which plots 300x500 area by given matrix, e.g.
command pplot 1,1, plots 300x500 area, upper right corner for plotting is 0,0
command pplot 2,1, plots 300x500 area, upper right corner for plotting is 500,0
command pplot 3,2, plots 300x500 area, upper right corner for plotting is 1000, 300
This matrix plot saves me to make boring manual plot after plot.
Now I would like to plot all diagrams using one command, so I need to test if block exists for example coordinates 2,2.
If block exists in coordinates plot 300x500 area. Upper right corner for plotting is 500,300.
I havent done this kind of "if block exists program" before, so your professional help would be needed.
Welcome to AUGI, the following is the plot program we use, we always plot to file, so It is used to automate the naming and saving of the plot file, but it does rely on the location of our titleblock, obviously we dont want our drawings plotting to the file and cutting off half the plot with no way to verify until we are ready to plot. The coding in red is probably what you need, it basically looks to see if our titleblock is located at 0,0,0, if it is, it continues, if it isnt, it opens up the standard plot dialog.
(command "undefine" "plot")
(defun C:PLOT (/ ss App Doc Dwgprops dname name file)
(vl-load-com)
;;===============================================
;; L o c a l F u n c t i o n s
;;===============================================
;; error function & Routine Exit
(defun *error* (msg)
(if
(not
(member
msg
'("console break"
"quit / exit abort"
""
)
) ;_ end of member
) ;_ end of not
(progn
(princ (strcat "\nError: " msg))
(initdia)
(command "_.PLOT")
) ;end progn
) ; endif
(restore_sys_vars) ; reset vars
) ;_ end of defun
;; Function to save system variables in global variable
;; call to function
;; (save_sys_vars '("CMDECHO" "FILEDIA"))
(defun save_sys_vars (lst)
(setq *sysvarlist* '())
(repeat (length lst)
(setq *sysvarlist*
(append *sysvarlist*
(list (list (car lst) (getvar (car lst))))
) ;_ end of append
) ;_ end of setq
(setq lst (cdr lst))
) ;_ end of repeat
) ;_ end of defun
;; Function to reset system variables
(defun restore_sys_vars ()
(repeat (length *sysvarlist*)
(setvar (caar *sysvarlist*) (cadar *sysvarlist*))
(setq *sysvarlist* (cdr *sysvarlist*))
) ;_ end of repeat
) ;_ end of defun
(save_sys_vars '("CMDECHO" "FILEDIA"))
(setvar "cmdecho" 0)
(setvar "filedia" 0)
;| (SETQ spellselect
(SSGET "all"
(LIST '(-4 . "<AND")
(CONS 410 (GETVAR "ctab"))
'(-4 . "<NOT")
'(-4 . "<AND")
'(0 . "INSERT")
'(2 . "M*")
'(-4 . "AND>")
'(-4 . "NOT>")
'(-4 . "AND>")
) ;end of LIST
) ;end of ssget
) ;end setq
;(if (/= spellselect nil)
;(COMMAND "SPELL" spellselect "")
;);end if
(setq spellselect nil)|;
(setvar "expert" 5)
(if (setq TblkData (vlax-ldata-get "TitleBlock" "TblkData"))
(setq dname (strcat (vl-filename-directory
(cdr (assoc (getvar "dwgname") TblkData))
) ;_ end of vl-filename-directory
"\\"
) ;_ end of strcat
) ;_ end of setq
(setq dname (getvar "DWGPREFIX"))
) ;_ end of if
(setq filename (getvar "DWGNAME"))
(setq dir (strcat dname "PLOTS\\"))
(vl-mkdir dir)
(setq extA (getvar "ctab"))
(if (/= (setq ss
(ssget
"_x"
(list
'(-4 . "<and")
'(0 . "insert")
(CONS 410 (GETVAR "ctab"))
'(2
.
"TBL13,TBL14,TBL14TEXTWRAP,TBL15,CTLB,CTLB2,CTLB3,MDOT SD TBLK,WJITBLK24x36,WJITBLKCOVER24x36,WJITBLKCOVER24x36 - ACRC"
)
(CONS 10 '(0 0 0))
'(-4 . "and>")
) ;end list
) ;end ssget
) ;end setq
nil
) ;end =
(PROGN
(if (and
(or (= (wcmatch extA "X####-@*") t)
(= (wcmatch extA "X####-##") t)
(= (wcmatch exta "##-###-*") t)
) ;_ end of or
(/= (getCurrentPagesetup (getvar "ctab")) "24X36C"))
(progn
(setq file (strcat dir extA ".PLT"))
(setq tfresult
(dwpMsgbox
"WIGHTMAN CAD WARNING"
(strcat "Do you wish to plot to file and overwrite?"
"\n"
"(If yes click ok if not click cancel)"
) ;_ end of strcat
vlax-vbOKCancel
vlax-vbExclamation
) ;_ end of dwpMsgbox
;|end dwgmsgbox|;
) ;end setq
;;PLOT DIRECTLY TO FILE?
(if (= tfresult 1)
(progn
(command "-psetupin" "page setup" "*")
(if (/= (setq ss (ssget "_x"
(list '(-4 . "<and")
'(0 . "insert")
(CONS 410 (GETVAR "ctab"))
'(2 . "TBL15")
'(-4 . "and>")
) ;_ end of list
;|end list|;
) ;_ end of ssget
;|end ssget|;
) ;_ end of setq
;|end setq|;
nil
) ;end =
(setq pagesetup "30x42PS")
) ;end if
(if (/= (setq ss
(ssget
"_x"
(list
'(-4 . "<and")
(cons 0 "insert")
(CONS 410 (GETVAR "ctab"))
(cons
2
"TBL14,TBL14TEXTWRAP,TBL13,CTLB,CTLB2,CTLB3,MDOT SD TBLK"
) ;_ end of cons
'(-4 . "and>")
) ;_ end of list
;|end list|;
) ;_ end of ssget
;|end ssget|;
) ;_ end of setq
;|end setq|;
nil
) ;end =
(setq pagesetup "24x36PS")
) ;end if
(if (/= (setq ss
(ssget
"_x"
(list
'(-4 . "<and")
(cons 0 "insert")
(CONS 410 (GETVAR "ctab"))
(cons
2
"WJITBLK24x36,WJITBLKCOVER24x36,WJITBLKCOVER24x36 - ACRC"
) ;_ end of cons
'(-4 . "and>")
) ;_ end of list
;|end list|;
) ;_ end of ssget
;|end ssget|;
) ;_ end of setq
;|end setq|;
nil
) ;end =
(setq pagesetup "WJI24x36PS")
) ;end if
(command ".-PLOT" "N"
;|Detailed plot configuration? [Yes/No] <No>: N|;
"" ;|Enter a layout name or [?] <Layout1>:|;
pagesetup ;|Enter a page setup name <>:|; ""
;|Enter an output device name or [?] <current>:|;
"y"
;|Write the plot to a file [Yes/No] <N>: y|;
file
;|Enter file name <\\maverick\engineering\x5405\RCp01001-Layout1.PLT>:|;
"y"
;|Save changes to page setup [Yes/No]? <N> n|;
"y" ;|Proceed with plot [Yes/No] <Y>:|;) ;_ end of command
;end command
) ;end progn
(progn ;if you wish not to plot directly to file
(initdia)
(command "_.PLOT")
) ;end progn
) ;end tfresult if
) ;progn
(progn
(initdia)
(command "_.PLOT")
) ;_ end of progn
) ;end if ;end condition
) ;end progn if inserted at 0,0
(progn
(initdia)
(command "_.PLOT")
) ;end progn block inserted at 0,0 f
) ;end if block inserted
(*error* "") ; reset sysvars
) ;end defun
(defun getCurrentPagesetup (layout / lst data)
(setq lst (dictsearch (namedobjdict) "acad_layout"))
(setq lst (dictsearch (cdar lst) layout))
(setq lst (member '(100 . "AcDbPlotSettings") lst))
(setq data (cadr lst))
(if (and (= 1 (car data)) (/= "" (cdr data)))
(cdr (assoc 1 lst))
) ;_ end of if
) ;_ end of defun
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.