AutoLISP: Interior Intersections of closed Polylines

This is the last of the polyline routines that I have for now. This one lets you select to closed objects and will keep the area that the two objects share and trim away the rest. Even though this can be done by using the TRIM command and hitting <enter> twice, this routine is nice because it works great for cluttered areas…

Here’s how:

  • PLINT <enter> to start (PolyLine INTersection)
  • Select the closed objects <enter>
  • Selection can be a window selection

;Shusei Hayashi
;OffshoreCad&Management Inc.
;10F Jaka Bldg., 6780 Ayala Ave.,
;Makati, Philippines
;http://www.offshorecad.com.ph/
;http://www.offshore-management.com.ph/
(defun c:PLINT (/ ObjNameL MadeObjL LastOb)
(princ "\n Intersect polylines")
(princ "\n **********************************")
(setq *error* *myerror*)
(SD1028)
(setq ObjSet nil)
(while (= ObjSet nil)
(setq ObjSet (ssget '((-4 . "<OR")
(0 . "LWPOLYLINE")
(0 . "ELLIPSE")
(0 . "CIRCLE")
(0 . "POLYLINE")
(0 . "LINE")
(0 . "ARC")
(-4 . "OR>")
)
)
)
)
(setq i -1
ObjNameL nil
)
(repeat (setq m (sslength ObjSet))
(setq ObjNameL (cons (ssname ObjSet (setq i (1+ i))) ObjNameL))
)
(Procedure_1708 ObjNameL) ;Region
(Procedure_1708_2 MadeObjL) ;Union
(SD2056)
(setq *error* nil)
(princ)
)
;*********;Union
(defun Procedure_1708_2 (ObjL /)
(command ".intersect")
(mapcar 'command MadeObjL)
(command "")
(setq LastOb (entlast)
MadeObjL nil
)
(command ".EXPLODE" (entlast))
(while (setq LastOb (entnext LastOb))
(setq MadeObjL (cons LastOb MadeObjL))
)
(command ".PEDIT" "M")
(mapcar 'command MadeObjL)
(command "" "Y" "J" "0.000" "")
)
;*********;Region
(defun Procedure_1708 (ObjL /)
(setq LastOb (entlast))
(command ".region")
(mapcar 'command ObjNameL)
(command "")
(while (setq LastOb (entnext LastOb))
(setq MadeObjL (cons LastOb MadeObjL))
)
MadeObjL
)
;
(defun SD1028 ()
(setq OldCmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "undo" "be")
(setq OldOsmode (getvar "OSMODE"))
(setq OldLayer (getvar "CLAYER"))
(setq OldLType (getvar "CeLType"))
(setq OldCeLWeight (getvar "CeLWeight"))
(setq OldColor (getvar "CeColor"))
(setq OldOrtho (getvar "ORTHOMODE"))
(setq OldDStyle (getvar "DIMSTYLE"))
(setq OldExpert (getvar "Expert"))
(setvar "EXPERT" 0)
(princ)
)
;********************************
(defun SD2056 ()
(setvar "OSMODE" OldOsmode)
(command "undo" "end")
(setvar "CLAYER" OldLayer)
(setvar "CeLType" OldLType)
(setvar "CeLWeight" OldCeLWeight)
(setvar "CeColor" OldColor)
(setvar "ORTHOMODE" OldOrtho)
(setvar "Expert" OldExpert)
(if (and (/= (getvar "DIMSTYLE") OldDStyle)
(tblsearch "DIMSTYLE" OldDStyle)
)
(command "-dimstyle" "Restore" OldDStyle)
)
(setvar "CMDECHO" OldCmdEcho)
(princ)
)
;********************************
(defun *myerror* (msg)
(setq *error* nil)
(SD2056)
(princ "\n Error in SpeedDraftLT")
(princ)
)
(princ "\n Command Name: PLINT Intersect polylines\n")
(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, AutoLISP: Polylines. Bookmark the permalink.

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