[CAD-MAP-15]: Memotong Gambar dengan Express Tools : Extrim.lsp

Reference : Autocad Online Help Manual
Platform : Autocad
Download : download

 

Sekitar tahun 1999, saya sering menggunakan fasilitas memotong-motong peta atau clipping peta menggunakan tool "cookie cutter" pada menu express tools. Sayangnya setelah Autocad 2005, fasilitas tersebut sudah dihilangkan dari express tools. Pada berbagai forum autodesk menyarakan untuk menggunakan fungsi yang hampir sama dengan "cookie cutter" yaitu perintah extrim.lsp yang juga terdapat pada menu express tools.

Misalkan saya mempunyai peta bidang tanah, kemudian akan dipotong sesuai dengan batas polyline berwarna merah:

  1. ketik di command:extrim
  2. pilih polylines warna merah sebagai batas polyline
  3. kemudian click area di luar batas merah / polyline merah
image image
Sebelum dipotong Setelah dipotong

Hasil perintah extrim masih meninggal objects di luar garis potong, sehingga jika object tersebut tidak diinginkan atau dihilangkan, maka dilakukan pemilihan object secara manual. Agar proses erase atau delete tidak dilakukan secara manual, Saya telah melakukan sedikit modifikasi autolisp yang dibuat oleh azarko di http://forums.augi.com/showthread.php?55056-Erasing-everything-outside-a-boundary

Berikut modifikasi autolisp yang dimaksud:

;function: delete all entities outside closed polylines.
;required "extrim.lsp" from express tools
;the lisp is modification from "Erases Everything OutSide Contour Delete with Extrim"
;published on : http://forums.augi.com/showthread.php?55056-Erasing-everything-outside-a-boundary
;modified by: zainul_ulum@cbn.net.id
;modification-01: 30 March 2018
;additonal requirement: closed polylines as boundary for clipping/trimming are located on layer "z_clip"

(defun c:zdob ( / *error* o_cmdecho o_osmode clip_layer aDoc ff filter ss nn kk en)

  (defun *error* (msg);;error handling
    (princ msg);display error message
    (setvar "cmdecho" o_cmdecho);restore to prev cmdecho
    (setvar "osmode" o_osmode);restore to old prev mode
    ;end undo marking
    (vla-EndUndoMark aDoc)
      );end error handling

 
  (vl-load-com);load autolisp com
  (setq o_cmdecho (getvar "cmdecho"));get current cmdecho variable
  (setq o_osmode (getvar "osmode"));get current osnap variable
  (setq clip_layer "z_clip");layer where boudary polylines are located
  (setq aDoc (vla-get-activedocument (vlax-get-acad-object)));get activedocument / active document

  ;setting new system variables prior to process trimming
  (setvar "cmdecho" 0)
  (setvar "osmode" 0)

  ;starting undo Marking
  (vla-StartUndoMark aDoc)

  ;select one polyline boundaries on layer z_clip
  (setq filter (cons 8 clip_layer))
  (setq ss (ssget ":S" (list filter)))
  (setq en (ssname ss 0)); select only one entity
    (if
          (wcmatch (cdr (assoc 0 (entget en))) "*POLYLINE")
    (progn
      ;start trimming
      (delete_outside_boundary en)
      ;save trimmed drawing
      ;start
      );end progn "*POLYLINE"
    );end if
       
;restore prev variables and end undo marking
    (setvar "cmdecho" o_cmdecho);restore to prev cmdecho
    (setvar "osmode" o_osmode);restore to old prev mode
    (vla-EndUndoMark (vla-EndUndoMark aDoc))
);end obd
(princ "\nType zdob")
(defun delete_outside_boundary (en)
  ;some functions are referred to extrim.lsp
  (setq bbox (ACET-ENT-GEOMEXTENTS en))
  (setq bbox (mapcar ‘(lambda (x) (trans x 0 1)) bbox))
  (setq lst (ACET-GEOM-OBJECT-POINT-LIST en 1e-3))
  (ACET-SS-ZOOM-EXTENTS (ACET-LIST-TO-SS (list en)))
  (command "_.Zoom" "0.95x")
  (if (null etrim)
    (load "extrim.lsp")
    );end if

  (etrim en
     (polar
       (car bbox)
       (angle (car bbox) (cadr bbox))
       (* (distance (car bbox) (cadr bbox)) 1.1))
     );end etrim
  (if (and (setq ss (ssget "_CP" lst))
       (setq ssall (ssget "_X" (list (assoc 410 (entget en)))))
       );and
    (progn
      (setq lst (vl-remove-if ‘listp (mapcar ‘cadr (ssnamex ss))))
      (foreach e1 lst (ssdel e1 ssall))
      (ACET-SS-ENTDEL ssall)
      );end progn
    );end if
    ;(command "_erase" en "")
);end delete outside boundary

Cara penggunaan program di atas adalah:

  1. Copy >> paste program di atas ke notepad.
  2. Simpan file dengan extensi .lsp misal nama filenya adalah dob.lsp
  3. Load program zdob.lsp ke autocad
  4. Ketik di menu command:zdob
  5. Pilih Polyline di layer :z_clip

Autolisp akan menghapus semua object selain objecs di dalam polyline.

image

 

~~~selamat mencoba~~~

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s