AutoLISP: Heal – Erase Block & Heal Polyline

Just like the previous post that heals lines, this routine will work on polylines.

it will erase the selected block and then join the two polylines into one.

Note: If the block is placed on a curved segment of a polyline, the joined area/distance will be made as a straight polyline segment.

There are 2 advantages of using this version over the routine that only works with lines:

1) The polyline routine lets you select any other type of object as well as polylines. And these objects will be turned into polylines.

2) It will join segments even when the block is obscuring the vertex (corner). the line routine will not do this.

Here’s how:

  • HEAL <enter>
  • Select the block that needs to be erased

That’s it


(defun c:heal  (/ block ll ur p1 p2)
      (vl-load-com)
      (setq block (car (entsel "\nSelect Block:")))
      (vla-getboundingbox (vlax-ename->vla-object block) 'll 'ur)
      (command "_.erase" block "")
      (command
            "_.pedit"
            "_m"
            (ssget "C"
                   (setq p1 (vlax-safearray->list ll))
                   (setq p2 (vlax-safearray->list ur)))
            ""
            "_join" "_Joint" "_Both"
            (distance p1 p2)
            "")
      (princ)
      )
Advertisement

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: Blocks, AutoLISP: Modify, AutoLISP: Polylines, Blocks, Polylines. Bookmark the permalink.

4 Responses to AutoLISP: Heal – Erase Block & Heal Polyline

  1. Tamas says:

    I am actually looking for the opposite. If i insert a block on the polyline then it’d create two separate pieces. Anybody has any solution?

  2. Pingback: AutoLISP: Updated Heal Line/Polyline | AutoCAD Tips

  3. Sir Good morning (Dubai).Sir this command dont work in Autocad 2014.
    how to work. heal command.
    AutoLISP: Heal – Erase Block & Heal Polyline

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 )

Connecting to %s