AutoLISP: Trim Objects on One Side

This routine is similar to the Express Tool EXTRIM (is covered near the bottom of the linked post) in that you select a cutting edge and then what side of the cutting edge you would like to trim. But the difference is that this routine lets you select what objects that cross the cutting edge will get trimmed. With the EXTRIM command, everything that crosses the edge gets trimmed. So this routine gives you that extra amount of control.

Here’s how:

  • MTR <enter> to start
  • Select an object to be the “cutting edge” <enter>
  • Select the objects that cross the “cutting edge” that you want trimmed <enter>
  • Specify which side of the “cutting edge” the objects should be trimmed on


;;; Trims objects on one side of a cutting edge.
;;; The difference between this and the Express Tool EXTRIM
;;; is that this will let you select what objects should be
;;; trimmed. EXTRIM trims everything that crosses the edge
;;;
;;;
(defun c:MTR(/ e t1 p l c)
  (setvar "CMDECHO" 0)
  (prompt "Select cutting edge(s)...")
  (setq e (ssget))
  (prompt "Select object(s) to trim...")
  (setq t1 (ssget))
  (setq p (getpoint"Pick side to trim..."))
  (command "TRIM" e "")
  (setq l (sslength t1))
  (setq c -1)
  (repeat l
    (setq c (1+ c))
    (command (list (ssname t1 c) p))
  )
  (command "")
  (prin1)
)
(princ)
Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, AutoLISP: Modify. Bookmark the permalink.

One Response to AutoLISP: Trim Objects on One Side

  1. Pingback: AutoLISP: EXTRIM Between Two Edges | AutoCAD Tips

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s