Autolisp: Polyline Outline of Objects

Here is another polyline routine that only works with closed objects (closed polylines, circles, ellipses…). This time however, you can select all of your objects at once and the combined outline of all of the shapes will be turned into a polyline.

Here’s how:

  • PLOUTLINE <enter> to start
  • Select all of the closed objects that overlap each other to make the outline <enter>

~enjoy

Link to original post at www.autocadtips.wordpress.com

;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:PLOUTLINE (/ MadeObjL ObjNameL ObjSet LastOb)
(princ "\n OUTLINE POLYLINES")
(princ "\n **********************************")
(setq *error* *myerror*)
(SD1028)
(setvar "CMDECHO" 0)
(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_1706) ;Region
(Procedure_1706_2) ;Union
(SD2056)
(setq *error* nil)
(princ)
)
;*********;Region
(defun Procedure_1706 (/)
(setq LastOb (entlast))
(command ".region")
(mapcar 'command ObjNameL)
(command "")
(while (setq LastOb (entnext LastOb))
(setq MadeObjL (cons LastOb MadeObjL))
)
MadeObjL
)
;*********;Union
(defun Procedure_1706_2 (/)
(mapcar '(lambda (x) (print (SD3511 0 x))) MadeObjL)
(command ".union")
(mapcar 'command MadeObjL)
(command "")
(setq LastOb (entlast)
MadeObjL nil
)
(command ".EXPLODE" LastOb)
(while (setq LastOb (entnext LastOb))
(setq MadeObjL (cons LastOb MadeObjL))
)
(command ".PEDIT" "M")
(mapcar 'command MadeObjL)
(command "" "Y" "J" "0.000" "")
)
(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)
)
(princ "\n (C)OffshoreCad&Management")
(setvar "CMDECHO" OldCmdEcho)
(princ)
)
;**********************
(defun SD3511 (g e)
(cond
((= (type e) 'ename) (cdr (assoc g (entget e))))
((= (type e) 'list) (cdr (assoc g e)))
)
)
;********************************
(defun *myerror* (msg)
(setq *error* nil)
(SD2056)
(princ "\n Error Cancelled")
(princ)
)
(princ "\n Command Name: PLOUTLINE \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.

One Response to Autolisp: Polyline Outline of Objects

  1. debalance says:

    For creating outlines of complex drawings the best way (in my opinion) is to use plugin TotalBoundary (www.totalboundary.com)

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