nguyentuyen6
-
Số lượng nội dung
212 -
Đã tham gia
-
Lần ghé thăm cuối
-
Ngày trúng
3
Bài đăng được đăng bởi nguyentuyen6
-
-
Mình mới check thử thì mục:
6: Chỉnh Plot Offset
hình như để căn lề bản vẽ thì để fit ở phía khung bên phải ?
Khi mình in có cần phải in trước 1 bản vẽ để TPL nhận canh lề bản vẽ không ?
Đúng rồi bạn! Nếu cái khung không để khoảng trống để sau đóng quyển thì chỉnh cái này để chừa phần gáy ra (Để center cũng tuơng đuơng với X=0, Y=0). Chỉ cần Preview là nó lưu lại cho các lần dùng sau.
- 1
-
Mình up sửa lại ở trang 1 rồi đấy bạn ạ. :D
-
Mình toàn dùng lisp của bạn để in vì thấy giao diện đơn giản và tính năng cũng đủ dùng. Tuy nhiên mình thấy chương trình còn hạn chế trong những trường hợp sau:
........
Mình mạo muội xin để xuất là bạn cho thêm một tính năng in theo bắt điểm đầu điểm cuối khung tên. Như vậy tuy thủ công một chút nhưng có thể in được tất cả các trường hợp bản vẽ. Cám ơn bạn.
- Mình vừa update thêm lựa chọn All trong Print Method. Bạn có thể chọn cả block, cả rec... bất kể nó ở layer nào.
Link download ở #1
- 2
-
Lâu lâu ko động đến lisp lại ngứa ngáy vào sửa cái này :D .
Updated Thêm chức năng "Plot scale" . Có thể chọn in theo các tỷ lệ khác nhau.
Link download tại #1
-
Lisp bị lỗi thường là do trong bản vẽ có block anonymous. Hoặc trục tọa độ bị đổi, bạn dùng lệnh "UCS" chọn "W" thì lại thấy nhé!!!
-
Mình không down được lisp ở #1. Nhưng các bác làm cho nó giống Qselect thì tuyệt (Có cả DCL)
hehe :D :D
-
Chào cả nhà ! các bác giúp em vấn đề nhỏ xí : em dùng hàm IF : em cần thỏa mản 2 hoặc nhiều điều kiện thì lisp chạy công tác 1 thì có cấu trúc của hàm IF như thế nào ah. ví dụ Đ/k : a>0 và b>0 thì công việc thứ nhất sẽ đc chạy..
Em xin cảm ơn !
(if (and (> a 0) (> b 0)) (progn (neu dung) ) (progn (neu sai) ) )
- 1
-
Mình thì toàn dùng comand mới khổ. Có bác nào có bộ entmake sẵn ko share cho e dùng chung với :lol:
-
HE. thực ra mình cũng mới biết thôi. Tại mình ko làm về dân dụng :lol: . Mà theo cái mặt bằng của bạn chủ Píc, tủ lạnh mà để đấy thì lúc mở tủ lấy đồ trong đó vất vả nhỉ :wacko:
- 1
-
Vâng em upfile lên mọi người nhận xét giúp e với,thank!
Không phải là hố nào đâu :D .Đấy là cái ký hiệu tủ lạnh bạn à. :lol: . Bạn xem tên của cái block ấy là thấy ngay, hehe
- 1
-
Lisp này nếu in sang pdf có thể ghi tên tự động thì tuyệt. Ví dụ mình in 20 bản vẽ cùng lúc, mình chỉ cần gõ tên bản vẽ đầu tiên là 5 thì nó sẽ tự động ghi tên các bản vẽ tiếp theo là 6,7...24. Chắc là khó đây vì cái này phụ thuộc vào kiểu máy in, không biết có kiểu máy in ảo nào có thể làm được việc đó không nhỉ. Nhân tiện hỏi bác nguyentuyen một chút, mình gõ lệnh (Command "PLOT" "") sao không thấy có phần Preview trong đó nhĩ. Thanks.
Có cái (command "PREVIEW") mà bạn. Nếu bạn biết Lisp thì mình làm cái đó ở chỗ này
(progn (command "-PLOT" "y" "Model" tenmayin tenkhogiay "m" ngangdoc "n" "Window" pt1 pt2 "f" xyoffset "y" tenplotstyle "y" "Wireframe" "n" "y" "n" ) (command "PREVIEW") )
- 1
-
Hề hề hề,
Nếu bác không phiền và không có gì ảnh hưởng tới công việc của bác, bác có thể post file *.lsp và *.dcl lên để mọi người tham khảo được không??? Mình cũng muốn mót thêm tí chút ở trong đó.
Chúc bác vui.
Hề hề!
E viết đc cái này là nhờ CadViet mà bác, làm sao mà để của riêng đc. Mới lại E code loạn xạ lắm, chả tối ưu gì cả, hoa mắt các bác ráng chịu nhé, hề hề...
Lisp:
(defun C:tpl (/ OldEcho OldOs blklist block dsmayin chonmayin udindex dskhogiay dsplotstyle MyPrinter dsblock ddiag dcl_id tenmayin pIndex tenkhogiay gIndex tenplotstyle psIndex tenblk method ;ssblk luupdf drectluupdf ;slfit recmethod lyrlist lyr tenlayer lIndex slsort luachonin luachonin1 ;*screenpoint* ;luu vi tri hop thoai center trucx trucy xyoffset ) (setq OldEcho (getvar "cmdecho")) (setvar "cmdecho" 0) (command "undo" "be") (vl-load-com) (princ "\n From nguyentuyen6 @CadViet \n Cai Express-Tools truoc khi su dung!!!" ) ;---------------------------------------------------------- ;----------kiem tra & tao regedit (registry) ;---------------------------------------------------------- ;--------- tao danh sach them vao dcl (setq dsmayin (PrintersList)) (setq dsplotstyle (PlotStyle)) (setq dsblock (BlockList)) (setq dslayer (LayerList)) ;dat fit to paper (ScaleFit) ;--- load dcl (setq ddiag 6) (while (>= ddiag 3) ;de cho dcl hien sau khi pick (setq dcl_id (load_dialog "TPL.dcl")) ;;;--- Load the dialog definition if it is not already loaded ;(if (not (new_dialog "TPL" dcl_id "" (cond ( *screenpoint* ) ( '(-1 -1) )))) (if (not (new_dialog "TPL" dcl_id)) (progn (alert "The TPL.DCL file could not be loaded!") (exit) ) ) ;-------------------------------- (start_list "layerlist" 3) (mapcar 'add_list dslayer) (end_list) ;kiem tra gia tri truoc do dc luu chua, neu luu roi thi set lai nhu lan truoc (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\layer") nil ) (set_tile "layerlist" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\layer") ) ) ;-------------------gan thong tin vao tenmayin (start_list "tenmayin" 3) (mapcar 'add_list dsmayin) (end_list) ;kiem tra gia tri truoc do dc luu chua, neu luu roi thi set lai nhu lan truoc (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenmayin") nil ) (set_tile "tenmayin" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenmayin") ) ) (update) ; update lai ten kho giay ;-------------------gan thong tin vao plotstyle (start_list "plotstyle" 3) (mapcar 'add_list dsplotstyle) (end_list) ;kiem tra gia tri truoc do dc luu chua, neu luu roi thi set lai nhu lan truoc (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenplotstyle") nil ) (set_tile "plotstyle" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenplotstyle") ) ) ;kiem tra gia tri truoc do dc luu chua, neu luu roi thi set lai nhu lan truoc (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenmayin") nil ) (set_tile "khogiay" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenkhogiay") ) ) (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\khungtenchuan") nil ) (set_tile "khungtenchuan" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\khungtenchuan") ) ) (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\printmethod") nil ) (set_tile "printmethod" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\printmethod") ) ) (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\sort") nil ) (set_tile "luachon" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\sort") ) ) (updatemethod) (selectsort) (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\plottofile") nil ) (progn (set_tile "tenduongdan" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\plottofile") ) (vlax-put-property (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Output ) 'DefaultPlotToFilePath (vl-registry-read "HKEY_CURRENT_USER\\TPL\\plottofile") ) ) (progn (set_tile "tenduongdan" (vlax-get-property (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Output ) 'DefaultPlotToFilePath ) ) ) ) ;;;laygia tri trong phan plotoffset (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\center") nil ) (set_tile "center" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\center") ) ) (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\offsetx") nil ) (set_tile "trucx" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\offsetx") ) ) (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\offsety") nil ) (set_tile "trucy" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\offsety") ) ) (offset) ;;;;---------------fit to paper ;;; ;;; ;;tu ;;; (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\fittopaper\\tu") ;;; nil ;;; ) ;;; (set_tile "numerator" ;;; (vl-registry-read "HKEY_CURRENT_USER\\TPL\\fittopaper\\tu") ;;; ) ;;; ) ;;;;; mau ;;; (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\fittopaper\\mau") ;;; nil ;;; ) ;;; (set_tile "denominator" ;;; (vl-registry-read "HKEY_CURRENT_USER\\TPL\\fittopaper\\mau") ;;; ) ;;; ) ;;; ;; fit ;;; (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\fittopaper\\fit") ;;; nil ;;; ) ;;; (set_tile "fittopaper" ;;; (vl-registry-read "HKEY_CURRENT_USER\\TPL\\fittopaper\\fit") ;;; ) ;;; ) ; update lai method ;;; (updatefit) ;---------------------------------------------------------- ;;;-------------------gan thong tin vao blocklist ; (start_list "blocklist" 3) ; (mapcar 'add_list dsblock) ; (end_list) ;;;-------------------------- ;---------------------------------------------------------- ;;;--- If an action event occurs, do this function ;;; (action_tile "fittopaper" "(saveVars)(updatefit)") (action_tile "center" "(offset)") (action_tile "printmethod" "(updatemethod)") (action_tile "tenmayin" "(update)") (action_tile "print" ;"(setq ddiag 1)(setq *screenpoint* (done_dialog 1))(saveVars)(done_dialog)" "(setq ddiag 1)(offset)(saveVars)(done_dialog)" ) (action_tile "preview" "(setq ddiag 4)(offset)(saveVars)(done_dialog)" ) (action_tile "cancel" "(setq ddiag 2)(done_dialog)") (action_tile "khungten" "(setq ddiag 3)(saveVars)(done_dialog) " ) (action_tile "datduongdan" "(setq ddiag 5)(done_dialog)") (action_tile "luachon" "(selectsort)") ;---------------------------------------------------------- ;;;--- Display the dialog box (start_dialog) ;;;--- Unload the dialog box (unload_dialog dcl_id) ;;;--- If the user pressed the PRINT button (if (= ddiag 1) (Printtt ssblk) ) ;;;--- If the user pressed the PREVIEW button (if (= ddiag 4) (Preview) ) ;;;--- If the user pressed the Cancel button (if (= ddiag 2) (princ "\nTPL cancelled!") ) ;;;--- If the user pressed the Pick button (if (= ddiag 3) (laykungten) ) (if (= ddiag 5) (PlotToFile) ) ) ;while 4 ;---------------------------------------------------------- ;;;--- Suppress the last echo for a clean exit (command "undo" "e") (setvar "cmdecho" OldEcho) (princ "\n...Done...") (princ) ) (vl-load-com) ;-------------------------------------------------------------- (defun saveVars () ;;; luu gia tri de xu ly ;; lay ten may in (setq tenmayin (get_tile "tenmayin")) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\tenmayin" "" tenmayin ) ; luu ten may in (if (/= tenmayin "") (progn (setq pIndex (atoi tenmayin)) (setq tenmayin (nth pIndex dsmayin)) (setq tenmayin (acet-str-replace "\\" "\\" tenmayin)) ;thay \ = \\ ) ) ; lay kho giay (setq tenkhogiay (get_tile "khogiay")) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\tenkhogiay" "" tenkhogiay ) ;luu ten kho giay (if (/= tenkhogiay "") (progn (setq gIndex (atoi tenkhogiay)) (setq tenkhogiay (nth gIndex dskhogiay)) ) ) ; luu layer (setq tenlayer (get_tile "layerlist")) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\layer" "" tenlayer ) ;llay ten layer (if (/= tenlayer "") (progn (setq lIndex (atoi tenlayer)) (setq tenlayer (nth lIndex dslayer)) ) ) ; lay plotstyle (setq tenplotstyle (get_tile "plotstyle")) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\tenplotstyle" "" tenplotstyle ) ; luu plotstyle (if (/= tenplotstyle "") (progn (setq psIndex (atoi tenplotstyle)) (setq tenplotstyle (nth psIndex dsplotstyle)) ) ) ; lay blk (setq tenblk (get_tile "khungtenchuan")) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\khungtenchuan" "" tenblk ) ;luu ten kho giay ; lay blk (setq method (get_tile "printmethod")) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\printmethod" "" method ) (setq sort (get_tile "luachon")) ;luu sort (vl-registry-write "HKEY_CURRENT_USER\\TPL\\sort" "" sort ) ;luu offset (setq trucx (get_tile "trucx")) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\offsetx" "" trucx ) (setq trucy (get_tile "trucy")) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\offsety" "" trucy ) (setq center (get_tile "center")) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\center" "" center ) ;;; (vl-registry-write ;;; "HKEY_CURRENT_USER\\TPL\\fittopaper\\fit" ;;; "" ;;; (get_tile "fittopaper") ;;; ) ;;;;------------ ;;; (vl-registry-write ;;; "HKEY_CURRENT_USER\\TPL\\fittopaper\\tu" ;;; "" ;;; (get_tile "numerator") ;;; ) ;luu tu ;;;(vl-registry-write ;;; "HKEY_CURRENT_USER\\TPL\\fittopaper\\mau" ;;; "" ;;; (get_tile "denominator") ;;; ) ;luu mau ) ;;;------------------------------------------------------- (defun update () (setq chonmayin (get_tile "tenmayin")) ;(setq chonkhogiay (get_tile "khogiay")) (if (/= chonmayin "") (progn (setq udindex (atoi chonmayin)) (setq MyPrinter (nth udindex dsmayin)) (vla-put-ConfigName (ActLay) MyPrinter) (setq dskhogiay (PaperList)) (start_list "khogiay" 3) (mapcar 'add_list dskhogiay) (end_list) (if (/= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenkhogiay") nil ) (set_tile "khogiay" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenkhogiay") ) ) ) ) ) ;--------------------------------------------------------------- (defun Printtt (ssblk / i pt1 pt2 Rec blkname) ;(princ "\nChon khung ten can in:") (if (= tenblk nil) (progn (alert "\nBan chua chon khung ten chuan") (setq maublk (car (entsel "\nChon BLOCK khung ten chuan: ")) tenblk (cdr (assoc 2 (entget maublk))) ) ) ) ;---------------------------------------------- ; lua chon in rec hay blk (if (= slmethod "recmethod") (progn (princ "\nChon Rectangle can in:") (setq ssblk (ssget (list (cons 0 "LWPOLYLINE") (cons 8 tenlayer))) ) ) ) (if (= slmethod "blockmethod") (progn (princ "\nChon BLOCK khung ten:") (setq ssblk (ssget (list (cons 0 "INSERT") (cons 2 tenblk)))) ) ) ;--------------------------------------------- (if (= ssblk nil) (alert "!!! Khong co khung in !!!") (progn ; (setq ssblk (SSsort ssblk)) ; (setq ssblk (acet-list-to-ss ssblk)) ;======== (if (/= slsort "nsrt") (setq ssblk (SSsort ssblk) ssblk (acet-list-to-ss ssblk) ; mac dinh la in tu trai sang phai ) ) ;======== (setq i 0) (while (< i (sslength ssblk)) (setq blkname (ssname ssblk i)) (setq Rec (acet-ent-geomextents blkname) pt1 (nth 0 Rec) ;;LL pt2 (nth 1 Rec) ;;UR ) ;;;-----chia truong hop khung ngang, doc (BatDau) (command "RECTANG" pt1 pt2) (KetThuc) (setq el1 (entlast)) ;el1 ;-----lay dinh HCN = acet-geom-vertex-list (setq toadodinh (acet-geom-vertex-list el1) ; rpt4----rpt3 rpt1 (nth 0 toadodinh) ;lay dinh | el1 | rpt2 (nth 1 toadodinh) ;lay dinh rpt1----rpt2 rpt3 (nth 2 toadodinh) ;lay dinh rpt4 (nth 3 toadodinh) ;lay dinh dis12 (distance rpt1 rpt2) dis14 (distance rpt1 rpt4) ) ;setq ;----- Chia truong hop khung ngang va khung doc (if (> dis12 dis14) (setq ngangdoc "l") ;T (setq ngangdoc "p") ;F ) (command "ERASE" el1 "") ;;;----------------------------------------------- (if (or (= tenmayin "DWG To PDF.pc3") (= tenmayin "DWF6 ePlot.pc3") ) ;; lay ten ban ve (progn (setq luachonin (vl-string-right-trim ".dwg" (vlax-get-property (vla-get-activedocument (vlax-get-acad-object)) 'WindowTitle ) ) luachonin1 (itoa (1+ i)) ) (setq luachonin (strcat luachonin "-" luachonin1)) ) ;); dat ten ban ve cua file pdf xuat ra (setq luachonin "n") ) (command "-PLOT" "y" "Model" tenmayin tenkhogiay "m" ngangdoc "n" "Window" pt1 pt2 "f" xyoffset "y" tenplotstyle "y" "Wireframe" luachonin "y" "y" ) (setq i (1+ i)) ) ;while ) ;progn ) ;if (princ "\nDa in: <") (princ (sslength ssblk)) (princ "> ban ve") ) ;defun ;------------------------------------------------ (defun Preview (/ i pt1 pt2 Rec blkname) (princ "\nChon khung ten can xem truoc:") (if (= tenblk nil) (progn (alert "\nBan chua chon khung ten chuan") (setq maublk (car (entsel "\nChon BLOCK khung ten chuan: ")) tenblk (cdr (assoc 2 (entget maublk))) ) ) ) ;---------------------------------------------- ; lua chon in rec hay blk (if (= slmethod "recmethod") (progn (princ "\nChon Rectangle can xem:") (setq ssblk (ssget (list (cons 0 "LWPOLYLINE") (cons 8 tenlayer))) ) ) ) (if (= slmethod "blockmethod") (progn (princ "\nChon BLOCK can xem:") (setq ssblk (ssget (list (cons 0 "INSERT") (cons 2 tenblk)))) ) ) ;---------------------------------------------- (if (= ssblk nil) (alert "!!! Kiem Tra Lai Print Method !!!") (progn ;======== (if (/= slsort "nsrt") (setq ssblk (SSsort ssblk) ssblk (acet-list-to-ss ssblk) ; mac dinh la in tu trai sang phai ) ) ;======== (setq i 0) (while (< i (sslength ssblk)) (setq blkname (ssname ssblk i)) (setq Rec (acet-ent-geomextents blkname) pt1 (nth 0 Rec) ;;LL pt2 (nth 1 Rec) ;;UR ) ;;;-----chia truong hop khung ngang, doc (BatDau) (command "RECTANG" pt1 pt2) (KetThuc) (setq el1 (entlast)) ;el1 ;-----lay tile, mac dinh la :1 ;-----lay dinh HCN = acet-geom-vertex-list (setq toadodinh (acet-geom-vertex-list el1) ; rpt4----rpt3 rpt1 (nth 0 toadodinh) ;lay dinh | el1 | rpt2 (nth 1 toadodinh) ;lay dinh rpt1----rpt2 rpt3 (nth 2 toadodinh) ;lay dinh rpt4 (nth 3 toadodinh) ;lay dinh dis12 (distance rpt1 rpt2) dis14 (distance rpt1 rpt4) ) ;setq ;----- Chia truong hop khung ngang va khung doc (if (> dis12 dis14) (setq ngangdoc "l") ;T (setq ngangdoc "p") ;F ) (command "ERASE" el1 "") ;;;----------------------------------------------- (if (or (= tenmayin "") (= tenkhogiay "")) (progn (princ "\nChua chon may in, kho giay!!!") (princ) ) (progn (command "-PLOT" "y" "Model" tenmayin tenkhogiay "m" ngangdoc "n" "Window" pt1 pt2 "f" xyoffset "y" tenplotstyle "y" "Wireframe" "n" "y" "n" ) (command "PREVIEW") ) ) (setq i (1+ i)) ) ;while ) ;progn ) ;if ) ;defun ;------------------------------------------------ (defun BatDau () (setq OldOs (getvar "osmode")) (setvar "osmode" 0) ) (defun KetThuc () (setvar "osmode" OldOs) (princ)) ;------------------------------------------------ (defun updatemethod () ;;;--- Get the key of the choice made (setq slmethod (get_tile "printmethod")) (if (= slmethod "recmethod") (progn (mode_tile "khungtenchuan" 1) (mode_tile "khungten" 1) (mode_tile "rec" 0) (mode_tile "layerlist" 0) ) ) (if (= slmethod "blockmethod") (progn (mode_tile "khungtenchuan" 0) (mode_tile "khungten" 0) (mode_tile "rec" 1) (mode_tile "layerlist" 1) ) ) ) (defun selectsort () (setq slsort (get_tile "luachon")) ) (defun offset () (setq center (atoi (get_tile "center"))) (if (= center 0) (progn (setq trucx (get_tile "trucx")) (setq trucy (get_tile "trucy")) (setq xyoffset (LM:lst->str (list trucx trucy) ",")) (mode_tile "trucx" 0) (mode_tile "trucy" 0) ) ) (if (= center 1) (progn (setq xyoffset "c") (mode_tile "trucx" 1) (mode_tile "trucy" 1) ) ) ) ;;;;;;-------------------------------------- ;;;(defun updatefit () ;;;;;;--- Get the key of the choice made ;;; (setq fit (get_tile "fittopaper")) ;;; (if (= fit "fit") ;;; (progn ;;; (vlax-put-property (ActLay) 'UseStandardScale "TRUE") ;;; (mode_tile "numerator" 1) ;;; (mode_tile "denominator" 1) ;;; ;(princ "\nFit") ;;; ) ;;; ) ;;; (if (= fit "custom") ;;; (progn ;;; (setq numerator (distof (get_tile "numerator")) ;;; denominator (distof (get_tile "denominator"))) ;;; (vlax-put-property (ActLay) 'UseStandardScale "FALSE") ;;; (vla-SetCustomScale (ActLay) numerator denominator); thiet lap ti le in ;;; ;(princ "\nCustom") ;;; ;(vla-Regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport) ;;; ;;; (mode_tile "numerator" 0) ;;; (mode_tile "denominator" 0) ;;; ) ;;; ) ;;;) ;;;;;------------------- ;;;;------------------------------------------------ (defun PlotToFile () (setq luupdf (getfiled " TPL-Save In:" (vlax-get-property (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Output ) 'DefaultPlotToFilePath ) "" 1 ) ) (if (/= luupdf nil) (progn (setq drectluupdf (vl-filename-base luupdf)) ; (setq luupdf (vl-string-right-trim drectluupdf luupdf)) (vlax-put-property (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Output ) 'DefaultPlotToFilePath luupdf ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\plottofile" "" luupdf ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\plottofile" "" luupdf ) (set_tile "tenduongdan" (vl-registry-read "HKEY_CURRENT_USER\\TPL\\plottofile") ) ) ) ) ;;;-------------------------------------------------- (defun SSsort (ss) ;;;--- Get the key of the choice made (if (= slsort "l2r") (progn (princ "\nChon thu tu in: Left->Right") (setq lst (ss2ent ss) lst (vl-sort lst '(lambda (e1 e2) (< (cadr (assoc 10 (entget e1))) (cadr (assoc 10 (entget e2))) ) ) ) ) ) (progn (princ "\nChon thu tu in: Top->Bottom") (setq lst (ss2ent ss) lst (vl-sort lst '(lambda (e1 e2) (> (caddr (assoc 10 (entget e1))) (caddr (assoc 10 (entget e2))) ) ) ) ) ) ) ) ;---------------------------------- (defun BlockList () ; lay danh sach block trong ban ve (setq blklist (list)) (setq block (tblnext "BLOCK" T)) (setq blklist (append blklist (list (cdr (assoc 2 block))))) (while (setq block (tblnext "BLOCK")) (setq blklist (append blklist (list (cdr (assoc 2 block))))) ) ) (defun LayerList () ; lay danh sach block trong ban ve (setq lyrlist (list)) (setq layr (tblnext "LAYER" T)) (setq lyrlist (append lyrlist (list (cdr (assoc 2 layr))))) (while (setq layr (tblnext "LAYER")) (setq lyrlist (append lyrlist (list (cdr (assoc 2 layr))))) ) ) ;;;------------------------------------------------------- (defun ActLay () ;;;get Active Layout (vla-get-ActiveLayout (vla-get-activedocument (vlax-get-acad-object)) ) ) ;;;------------------------------------------------------- (defun PrintersList () ;;;get Printers List- danh sach may in:STRING (vla-RefreshPlotDeviceInfo (ActLay)) (vlax-safearray->list (vlax-variant-value (vla-GetPlotDeviceNames (ActLay))) ) ) ;;;------------------------------------------------------- (defun PaperList (/ PLObj PSL) ;;;get Paper Size List- danh sach kho giay: STRING (setq PLObj (vla-GetCanonicalMediaNames (ActLay))) (foreach i (vlax-safearray->list (vlax-variant-value PLObj)) (setq PSL (append PSL (list (vla-GetLocaleMediaName (ActLay) i)))) ) ) ;;;------------------------------------------------------- (defun PlotStyle () ;;;danh sach style:STRING (vla-RefreshPlotDeviceInfo (ActLay)) (vlax-safearray->list (vlax-variant-value (vla-GetPlotStyleTableNames (ActLay))) ) ) ;;;------------------------------------------------------- (defun ScaleFit () ;;;Chuyen sang chon "Fit to paper" (vlax-put-property (ActLay) 'StandardScale acScaleToFit) (vlax-put-property (ActLay) 'PaperUnits acMillimeters) ; mac dinh ma mm ) ;(vlax-put-property (ActLay) 'UseStandardScale "TRUE") ; TRUE: set la chon fit to paper, FALSE :set la` bo? chon abc ;-------------------------------------------------------------- (defun registry () (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenkhogiay") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\tenkhogiay") ) (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenmayin") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\tenmayin") ) (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\tenplotstyle") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\tenplotstyle") ) (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\khungtenchuan") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\khungtenchuan") ) (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\printmethod") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\printmethod") ) (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\plottofile") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\plottofile") ) (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\layer") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\layer") ) (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\sort") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\sort") ) (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\center") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\center") ) (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\offsetx") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\offsetx") ) (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\offsety") nil ) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\offsety") ) ;;;;tu ftpaper ;;; (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\fittopaper\\tu") ;;; nil ;;; ) ;;; (vl-registry-write "HKEY_CURRENT_USER\\TPL\\fittopaper\\tu") ;;; ) ;;;;mau ftpaper ;;; (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\fittopaper\\mau") ;;; nil ;;; ) ;;; (vl-registry-write "HKEY_CURRENT_USER\\TPL\\fittopaper\\mau") ;;; ) ;;;; ftpaper ;;; (if (= (vl-registry-read "HKEY_CURRENT_USER\\TPL\\fittopaper\\fit") ;;; nil ;;; ) ;;; (vl-registry-write "HKEY_CURRENT_USER\\TPL\\fittopaper\\fit") ;;; ) ) (defun ss2ent (ss / sodt index lstent) (setq sodt (if ss (sslength ss) 0 ) index 0 ) (repeat sodt (setq ent (ssname ss index) index (1+ index) lstent (cons ent lstent) ) ) (reverse lstent) ) ;------------------------------------ (defun LM:lst->str (lst del) ( (lambda (str) (foreach x (cdr lst) (setq str (strcat str del x))) str ) (car lst) ) ) ;;;------------------------------ (defun c:in () (c:tpl)) (defun c:mp () (c:tpl)) (defun laykungten () (setq maublk (car (entsel "\nChon BLOCK khung ten: "))) (if (= (cdr (assoc 0 (entget maublk))) "INSERT") (progn (setq tenblk (cdr (assoc 2 (entget maublk)))) (vl-registry-write "HKEY_CURRENT_USER\\TPL\\khungtenchuan" "" tenblk ) ; luu ten may in ) (progn (alert "!!!Khung Ten Phai La BLOCK!!!") (setq tenblk (vl-registry-read "HKEY_CURRENT_USER\\TPL\\khungtenchuan") ) ) ) )
DCL:
TPL : dialog { label = " TPL-IN-MP - nguyentuyen86"; : column { : boxed_row { label = "Setting"; : radio_column { key = "mychoice"; : popup_list { key = "tenmayin"; label = "Printer "; fixed_width_font = fasle; //width = 30; value = ""; } : popup_list { key = "khogiay"; label = "Paper Size"; fixed_width_font = fasle; // width = 30; value = ""; } : popup_list { key = "plotstyle"; label = "Plot Style "; fixed_width_font = fasle; // width = 30; value = ""; } } } :row { : boxed_row { label = "Print Method"; : radio_column { key = "printmethod"; : radio_button { key = "blockmethod"; label = "Block"; value = 1; } : radio_button { key = "recmethod"; label = "Rectangle"; } } :column { :row { : edit_box { key = "khungtenchuan"; label = " "; width = 20; fixed_width_font = fasle; value = ""; } : button { key = "khungten"; label = "Pick"; is_default = false; } } :row { : popup_list { key = "layerlist"; label = "Layer"; fixed_width_font = fasle; width = 0; value = ""; } // : button { // key = "rec"; // label = "Creat Rec.."; // is_default = false; // width = 0; // } } } } } : boxed_row { label = "Plot To File "; : edit_box { key = "tenduongdan"; label = "Save in"; width = 30; fixed_width_font = fasle; value = ""; } : button { key = "datduongdan"; label = "..."; is_default = false; } } : boxed_row { label = "Sort"; : radio_row { key = "luachon"; : radio_button { key = "nsrt"; label = "Nomal"; value = 1; } : radio_button { key = "l2r"; label = "Left->Right"; } : radio_button { key = "t2b"; label = "Top->Bottom"; } } } : boxed_row { label = "Plot offset"; : toggle { key = "center"; label = "Center"; //width = 0; // fixed_width_font = fasle; value = "1"; } spacer_1; : edit_box { key = "trucx"; label = "X"; //width = 0; fixed_width_font = fasle; value = "1"; } : edit_box { key = "trucy"; label = "Y"; // width = 0; fixed_width_font = fasle; value = "1"; } } : boxed_row { : button { key = "print"; label = " Print "; is_default = true; } : button { key = "preview"; label = " Preview "; is_default = false; } : button { key = "cancel"; label = " Cancel "; is_default = false; is_cancel = false; } } : text { value = " nguyentuyen86@gmail.com"; } } }
- 4
-
Nhờ các bác xem giùm cách sử dụng initget:
Chỗ nhập đường kính thép mình muốn mặc định là 25 chỉ việc enter là sẽ hiểu nhưng lại không được,mong các bác xem lại cấu trúc giùm e.
Bạn thiếu hàm setq ở truớc n (getint "\nS.luong thep day mong:")
-
Bạn dùng Quick Select nhé :rolleyes:
tên lệnh: Qselect
-
Tiêu chí nên có thêm mục: file được down nhiều nhất. :)
Phần thưởng là 10 điểm <==> 10 nút thanks :lol:
Có cái thống kê số lần Download thì tuyệt :wub:
- 1
-
Vâng.Cảm ơn bác đã quan tâm. Em mần nó tiếp đây. Có gì mong bác xem dùm tiếp hộ em.
P/s: Em đã sửa lại và chạy ngon. Cảm ơn bác nguyentuyen6 nhiều.
Em đang mần cái bài toán trên, mong bác có thể gợi ý hoặc làm giúp em với. Em chưa biết các phương phức của lisp là mấy nên làm theo kiểu thủ công thế bác ạ. Cảm ơn bác nhiều.
Viết kiểu này đỡ phúc tạp hơn bạn nhỉ:
(defun c:goc () (setq p1 (getpoint "\n Chon diem thu nhat : ") goc (getangle p1 "\n Chon diem thu hai : ") ) (Rad_to_Do goc ) ) (defun Rad_to_Do(radian / Do) (setq Do (/ (* radian 180) pi)) )
- 1
-
Tạm thời em đang viết thực hiện tính góc hợp với trục X (hướng Đông làm chuẩn) theo chiều kim đồng hồ để tính góc tạo bởi 2 điểm kích trên màn hình nhưng nó vẫn bị lỗi tại chỗ nào đó.
Mình xem qua thấy chỗ này:
(setq Goc (Atan2 (dx dy))) >>>>>(setq Goc (Atan2 dx dy)) (thừa ngoặc)
Đoạn này cũng thấy thừa ngoặc ở hàm AND
(cond (((and (= dx 0) (> dy 0) )) (setq gocAtan (/ pi 2)) ) (((and (= dx 0) (< dy 0) )) (setq gocAtan (/ (* 3 pi) 2)) )
chuyển thành:
(cond ((and (= dx 0) (> dy 0) ) (setq gocAtan (/ pi 2)) ) ((and (= dx 0) (< dy 0) ) (setq gocAtan (/ (* 3 pi) 2)) )
Bạn cũng nên sửa đoạn này 1 chút nhìn cho nó trực quan:
p2 (getpoint "\n Chon diem thu hai : ")
thành
p2 (getpoint p1 "\n Chon diem thu hai : ")
- 1
-
Notepad++ v5.9
trong Phần mềm
Mình cũng dùng cái này song song với Vlide (Cho cả 2 phần đều mở 1 file líp 1 lúc, soạn bên Notepad++, còn debug, dàn code bên Vlide). thấy có mấy điểm hay là: khi dấu nháy chỉ vào dấu ngoặc nào thì nó cho ra dấu ngoặc còn lại (đỡ phải nháy đôi như vlide). Và khi bôi đen biến nào thì tất cả các biến có tên như thế sẽ sáng lên :rolleyes:
-
Bạn thử dùng lệnh PU xem
-
Lisp quá tuyệt vời bác. Thanks bác nhiều lắm. Nhờ lisp này mà mình đỡ tốn một khoản thời gian chuyển cad-> pdf. Mình cũng đã viết một lisp về in nhưng khá thủ công và không thể Multiple như của bác đựơc. Sao mình không thấy nút "Thanks" chỗ nào nhĩ. Một lần nữa xin cảm ơn nhuyentuyen
He, bác dí vào nút + màu xanh ý :lol:
- 5
-
Không bác nào hứng thú với vấn đề của mình hết nhỉ?
http://www.cadviet.com/forum/index.php?showtopic=13203&st=3440&gopid=143081entry143081
Chắc tại mọi người ngại down cái file của bạn :lol: . Bạn up ảnh trực tiếp lên đây thì tốt quá
-
Khoanh xung quanh các đối tượng đc chọn thì cái nào là cái nguồn trong các cái đó. Nếu thay 1 tập các text A = 1 tập các text B, bạn có đảm bảo số text chọn bằng nhau, hoặc theo đúng thứ tự mong muốn ?
P/S : với chọn khoanh : mình cũng tịt luôn điểm hay ở lisp này là change được text trong Block :)
=> Mình sẽ đưa cho bạn lựa chọn là chọn text nguồn hoặc đích đến bao giờ trúng thì thôi, OK ?
MÌnh nghĩ ý bạn kia là chọn text đích = ssget rồi thay tất cả trong đó y như nguồn :lol:
- 1
-
Khi làm việc thì chúng ta thường phải mở rất nhiều drawing, Thậm chí mở nhiều application Cad khác nhau.
Đến khi không làm nữa phải đóng tấc cả các bản vẽ, tấc cả Cad đang mở. Mỗi bản vẽ đóng phải trả lời các câu hỏi Yes/No question của Autodesk.
Diễn đàn có thể viết cho 2lisp thực hiện chức năng tắt tấc cả drawing trên tấc cả các cửa sổ Cad đang được mở với yêu cầu
+ 1 lisp tên lệnh "csn" (close save no) : đóng tấc cả drawing không lưu
+ 1 lisp tên lệnh "csy" (close save yes) : Lưu và đóng tấc cả drawing
(quit luôn thằng Cad App càng tốt)
Có thể diễn đàn đã có lisp này, Nhưng mình search thì không thấy!
Một số diễn đàn khác cũng có lisp chức năng trên nhưng không đầy đủ và như ý muốn được.
Cảm ơn diễn đàn!
Mình thấy cái này trên mạng bạn thử xem nhé:
(vl-load-com) (defun C:csn ( / dwg) (vlax-for dwg (vla-get-Documents (vlax-get-acad-object)) (if (= (vla-get-active dwg) :vlax-false)(vla-close dwg :vlax-false)) ) (command "._close" "_y") ) (defun C:csy ( / dwg) (vlax-for dwg (vla-get-Documents (vlax-get-acad-object)) (if (= (vla-get-active dwg) :vlax-false)(vla-close dwg :vlax-true)) ) (command "._close" "_n") )
- 1
-
các bác ơi sao e ấn vào nó cứ báo là chưa cài expresstoll thế mà e vẫn dùng được lệnh layiso và layon ầm ầm mà
MÌnh vừa sửa lại rồi bạn ạ. Bạn dơn lại nhé.
Mới update thêm cái Plot Offset!!
Các bạn Test giúp mình với nhé! :lol:
- 1
Thêm 1 lisp in nhiều bản vẽ
trong AutoLisp
Đã đăng · Trả lời báo cáo
nếu đặt lề trái bạn thử đăt lần lượt là 1,0 . 10,0. 50,0 Preview rồi xem nó thế nào