;; Version 2.3 - 2023-06-26; declaring global variables
;; Version 2.4 - 2024-05-17; printable A4 ; kp1 A3출력; kp2 A4출력가능
;; Version 2.41 - 2024-05-21; wcmatch 함수로 *A1*, *A3*, *A4* 포함문자 인식
;;
;; V2.4 주요 변경 사항
;; kp1 또는 kp2 실행후 도곽블럭을 선택하면 정수 스케일로 바로 출력함
;; 1) 피지컬 프린터 앞뒤로 cond 배치
;;(cond
;;((= _PPDEVICE 1) (setq OutputDevice pdev1_KM PaperSize pdev1_paper))
;;((= _PPDEVICE 2) (setq OutputDevice pdev1_KM PaperSize pdev2_paper)))
;;cond 함수 배치 함. 앞뒤로 배치해야 PLOTSETTING 에서 pdf 지정을 피지컬로 바꿈. 개선 필요.
;;
;; 2) KM:PLOTAREA 모듈에 A1, A3, A4 대각선 길이 선택.--> 용지에 맞게 출력 스케일 결정
;;
;; CODE begin
;;
;; INI.: Declaring Global Variables; 초기화: 전역변수 선언
(setq pensetting_KM "KM_GRAY.ctb"); pen setting
(setq pdfdev_KM "DWG_to_PDF(A3_KM).pc3" pdf_paperA3 "A3_PDF_KM")
(setq pdev1_KM "SINDOH D420(Black)" pdev1_paper "A3"); physical dev paper
(setq pdev2_KM "SINDOH D420(Black)" pdev2_paper "A4"); physical dev paper
;; endINI.: end Declaring Global Variables
;;
;;
(defun KM:PLOTNAME (/ dn tstmp path plt pltname ) ; return drawingno PdfName
;;get drwaing no.
(princ "\n***SELECT A DRAWING NO***:...\n")
(while (not (setq dn (ssget ":s" '((0 . "*TEXT"))))))
(setq drawingno (cdr (assoc 1 (entget (ssname dn 0)))))
;
;;Set PDFNAME; TimeStamp can be enabled if you want
;(setq tstmp (rtos (getvar "cdate") 2 6)); TimeStamp YYYYMMDD.hhmmss
(setq path (getvar "dwgprefix"))
;(setq plt (strcat path "PLOT" tstmp " "))
;(setq pltname (strcat plt drawingno ".pdf"))
;(setq PdfName pltname)
(setq PdfName (strcat path drawingno ".pdf"))
);defun km:plotname
;;
;;
(defun KM:PLOTAREA ( drawingbox PaperSize / ratio); return P1 P2 ort p_scale
(vl-load-com)
;;;get plot area
(vla-GetBoundingBox (vlax-ename->vla-object (ssname drawingbox 0)) 'MinPt 'MaxPt)
(setq P1 (vlax-safearray->list MinPt)); Points of Lower Left of Selected Entity
(setq P2 (vlax-safearray->list MaxPt)); Points of Upper Right of Selected Entity
(if (> 0.25 (/ (angle P1 P2) pi)) (setq ort "LANDSCAPE") (setq ort "PORTRAIT"))
(cond
((wcmatch PaperSize "A4") (setq paper_diagonal 363.7))
((wcmatch PaperSize "A3") (setq paper_diagonal 514.4))
((wcmatch PaperSize "A1") (setq paper_diagonal 1029.6))
);cond paper_diagonal
(setq ratio (/ (distance P1 P2) paper_diagonal))
(cond
((<= 1000 ratio) (setq plot_ratio (* 100 (atoi (rtos (/ ratio 100) 2 0)))))
((and (<= 100 ratio) (< ratio 1000)) (setq plot_ratio (* 10 (atoi (rtos (/ ratio 10) 2 0)))))
((> 100 ratio) (setq plot_ratio (atoi (rtos ratio 2 0))))
);cond ratio
;set p_scale "1=plot_ratio"
(setq p_scale (strcat "1=" (itoa plot_ratio)))
(princ)
);defun km:plotarea
;;
;;
(defun KM:PLOTSETTING ();/ drawingno dn tstmp path plt pltname)
;;plot setting
(setq DetailedPlotConfig "YES")
(setq LayoutName "")
(setq OutputDevice pdfdev_KM)
(setq PaperSize pdf_paperA3)
(setq PaperUnits "MILLIMETERS")
(setq Orientation ort)
(setq UpsideDown "NO")
(setq PlotArea "WINDOW")
(setq PlotScale p_scale)
(setq PlotOffset "CENTER")
(setq PlotStyle "YES")
(setq PlotTable pensetting_KM)
(setq LineWeights "YES")
;
(setq LineweightScale "NO");paperspace
(setq PaperspaceFirst "NO");paperspace
(setq HidePaperspaceObject "NO");paperspace
;
(setq ShadePlot "A");As displayed ;modelspace
;
(setq ChangePagesetup "NO")
(setq ProceedPlot "YES")
;
(setq ProccedPlotPREVIEW "NO")
(setq PREVIEW "PREVIOUS PLOT")
;
(princ)
);defun KM:PLOTSETTING
;;
;;
(defun KM:PLOTLOAD ();Plot Loading
;;
(command "._plot"
DetailedPlotConfig
LayoutName
OutputDevice
PaperSize
PaperUnits
Orientation
UpsideDown
PlotArea P1 P2
PlotScale
PlotOffset
PlotStyle
PlotTable
LineWeights
)
) ;defun KM:PLOTLOAD
;;
(defun KM:PLOTPROCEED ();Plot Proceeding
;;
(command
PdfName
ChangePagesetup
ProceedPlot
)
)
;;
(defun KM:PLOTp ();Plot Proceeding on Paperspace
;;
(command
LineweightScale
PaperspaceFirst
HidePaperspaceObject
);command plot
);defun KM:PLOT_paperspace
;;
(defun KM:PLOTm ();Plot Proceeding on Modelspace
;;
(command
ShadePlot
);command plot
);defun KM:PLOT_modelspace
;
(defun KM:INIT ()
(setvar "cmdecho" 0)
(setvar "filedia" 0)
(setvar "cmddia" 0)
(setvar "layereval" 0)
(setvar "layerevalctl" 0)
(princ)
);defun init
;
(defun KM:RESET ()
(setvar "cmdecho" 1)
(setvar "filedia" 1)
(setvar "cmddia" 1)
(setvar "layereval" 1)
(setvar "layerevalctl" 1)
(princ)
); defun reset
;;
;;
;;===================PLOT PDF with dwg-no=======================
;;
(defun KM:KPDF (); KM Plot Script PDF
;;
;;set Init
(KM:INIT)
(KM:PLOTNAME)
(princ "\n\n***SELECT A DRAWING TITLEBLOCK***:...\n")
(while (not (setq drawingbox (ssget ":s" '((0 . "INSERT"))))))
(setq PaperSize "A3")
(KM:PLOTAREA drawingbox PaperSize)
(KM:PLOTSETTING)
;
(if (= 0 (getvar "tilemode")); CHECKING TILEMODE
(progn (KM:PLOTLOAD) (KM:PLOTp) (KM:PLOTPROCEED))
(progn (KM:PLOTLOAD) (KM:PLOTm) (KM:PLOTPROCEED))
);if
;; Reset
(KM:RESET)
;
;;success plot
(prompt "\n...SUCCESS PLOT...\n")
(princ (strcat PdfName " " p_scale))
(princ)
;(command "close")
);defun KP PDF
;;
;;
;;===================PLOT PDF with dwg filename=======================
;;
(defun KM:KPDF0 (); KM Plot Script PDF
;;
;;set Init
(KM:INIT)
;(KM:PLOTNAME)with dwg filename ".dwg" -> ".pdf"
(setq PdfName (vl-string-subst ".pdf" ".dwg" (getvar "dwgname")))
(setq PdfName (strcat (getvar "dwgprefix") PdfName))
(princ "\n\n***SELECT A DRAWING TITLEBLOCK***:...\n")
(while (not (setq drawingbox (ssget ":s" '((0 . "INSERT"))))))
(setq PaperSize "A3")
(KM:PLOTAREA drawingbox PaperSize)
(KM:PLOTSETTING)
;
(if (= 0 (getvar "tilemode")); CHECKING TILEMODE
(progn (KM:PLOTLOAD) (KM:PLOTp) (KM:PLOTPROCEED))
(progn (KM:PLOTLOAD) (KM:PLOTm) (KM:PLOTPROCEED))
);if
;; Reset
(KM:RESET)
;
;;success plot
(prompt "\n...SUCCESS PLOT...\n")
(princ (strcat PdfName " " p_scale))
(princ)
;(command "close")
);defun KP PDF0 printing to path_dwg_filename.pdf
;;
;;
;;
;;===================PLOT PDF from ATTRIBUTE VALUE=======================
;;
(defun KM:KPDFATTRIB (); KM Plot Script PDF
;;
;;set Init
(KM:INIT)
;(KM:PLOTNAME_ATTRIB)
(princ "\n\n***SELECT A DRAWING TITLEBLOCK***:...\n")
(while (not (setq drawingbox (ssget ":s" '((0 . "INSERT"))))))
(KM:PLOTNAME_ATT drawingbox)
(KM:PLOTAREA drawingbox PaperSize)
(KM:PLOTSETTING)
;
(if (= 0 (getvar "tilemode")); CHECKING TILEMODE
(progn (KM:PLOTLOAD) (KM:PLOTp) (KM:PLOTPROCEED))
(progn (KM:PLOTLOAD) (KM:PLOTm) (KM:PLOTPROCEED))
);if
;; Reset
(KM:RESET)
;
;;success plot
(prompt "\n...SUCCESS PLOT...\n")
(princ (strcat PdfName " " p_scale))
(princ)
;(command "close")
);defun KP PDFB
;;
;;===================PLOT to PHYSICAL DEVICE=======================
;;
(defun KM:KPP (_PPDEVICE); KM Plot Script plots to PHYSICAL DEVICE
;;
;;set Init
(KM:INIT)
;;
(cond
((= _PPDEVICE 1) (setq OutputDevice pdev1_KM PaperSize pdev1_paper))
((= _PPDEVICE 2) (setq OutputDevice pdev1_KM PaperSize pdev2_paper))
)
;;
(princ "\n\n***SELECT A DRAWING TITLEBLOCKS***:...\n")
(while (not (setq drawingbox (ssget ":s" '((0 . "INSERT"))))))
;;
(KM:PLOTAREA drawingbox PaperSize)
(KM:PLOTSETTING)
;;
(cond
((= _PPDEVICE 1) (setq OutputDevice pdev1_KM PaperSize pdev1_paper))
((= _PPDEVICE 2) (setq OutputDevice pdev1_KM PaperSize pdev2_paper))
)
(setq PdfName "NO")
;;
(if (= 0 (getvar "tilemode")); CHECKING TILEMODE
(progn (KM:PLOTLOAD) (KM:PLOTp) (KM:PLOTPROCEED))
(progn (KM:PLOTLOAD) (KM:PLOTm) (KM:PLOTPROCEED))
);if
;; Reset
(KM:RESET)
;
;;success plot
(prompt (strcat "\n...SUCCESS PLOT " OutputDevice "... " p_scale "\n"))
;(princ (strcat PdfName " " p_scale))
(princ)
;(command "close")
);defun KPP plots to PHYSICAL DEVICE
;;
;;
(defun c:KP ()
(KM:KPDF)
)
(defun c:KP0 ()
(KM:KPDF0)
)
(defun c:KP1 ()
(KM:KPP 1)
)
(defun c:KP2 ()
(KM:KPP 2)
)
(defun c:KPP ()
(KM:KPDFATTRIB)
)
'autocad' 카테고리의 다른 글
Fix Relocate Sheet A1 (c:RS) (0) | 2024.05.23 |
---|---|
(wcmatch string pattern) (0) | 2024.05.20 |
LISP 스크립트 실행 시 에코 끄기 (0) | 2024.05.09 |
AutoCAD 빠르게 빠르게 (펌) (0) | 2024.05.07 |
모조리 0 레벨로 (2) | 2023.11.23 |