<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Replacing object with block lisp in AutoCAD Forum</title>
    <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219427#M288560</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is probably not a difficult thing to build a routine to do.&amp;nbsp;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For instance [very basic and tested all of &lt;EM&gt;once&lt;/EM&gt; in your sample drawing]:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)
(defun C:BoltSub (/ ss n bolt verts ctr)
  (setq ss (ssget "_X" '((0 . "LWPOLYLINE") (8 . "BULT") (90 . 2))))
  (repeat (setq n (sslength ss))
    (setq
      bolt (ssname ss (setq n (1- n)))
      verts (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget bolt))
      ctr (mapcar '/ (mapcar '+ (cdar verts) (cdadr verts)) '(2 2 2))
    ); setq
    (command "_.insert" "&lt;EM&gt;&lt;FONT color="#33cccc"&gt;YourBlockName&lt;/FONT&gt;&lt;/EM&gt;" "_none" ctr "" "" "")
    (entdel bolt)
  ); repeat
); defun&lt;/PRE&gt;
&lt;P&gt;Puts them on the current Layer, at a scale of 1 and rotation of 0.&amp;nbsp; Could be faster using (entmake) [in which case the 10 could be &lt;EM&gt;left in&lt;/EM&gt; the vertex entity-data entries, because that will be applicable to the insertion-point entry for the Block], could use the usual enhancements, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Mar 2016 19:55:11 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2016-03-16T19:55:11Z</dc:date>
    <item>
      <title>Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219093#M288552</link>
      <description>&lt;P&gt;I have got a drawing with lots of rund objects representing bolts.&lt;/P&gt;&lt;P&gt;I want to replace these objects with a certain block.&lt;/P&gt;&lt;P&gt;Anybody have a lisp for that?&lt;/P&gt;&lt;P&gt;The objects are rund polylines so it is difficult to extract any center point. That is a big problem!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 17:38:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219093#M288552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-16T17:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219129#M288553</link>
      <description>&lt;P&gt;What is a rund polyline? can you attach your drawing?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 17:53:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219129#M288553</guid>
      <dc:creator>Patchy</dc:creator>
      <dc:date>2016-03-16T17:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219234#M288554</link>
      <description>&lt;P&gt;Hi, I don´t know how those are created!&lt;/P&gt;&lt;P&gt;I can change thicknes to 0,0 and it is a polyline yet!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 18:33:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219234#M288554</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-16T18:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219275#M288555</link>
      <description>&lt;P&gt;They're Donuts [the Donut command makes LWPolylines] with zero inside radius.&amp;nbsp; A routine could certainly be made that would filter the&amp;nbsp;selection to allow only closed LWPolylines with a global width and two vertices, and only on a certain Layer [it seems you have one just for those], so it should be possible to narrow it down to just those, possibly &lt;EM&gt;without&lt;/EM&gt; even involving the User selecting anything.&amp;nbsp; Since Donuts are always made with two &lt;EM&gt;equal&lt;/EM&gt; half-circle arc segments, it could find the center of each by [among other ways] averaging the locations of those two vertices.&amp;nbsp; It could then use that location from each one&amp;nbsp;to Insert your Block, and delete the bolt if desired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is probably not a difficult thing to build a routine to do.&amp;nbsp; What is your Block name, and would it be Inserted at scale factors of 1 and rotation of 0?&amp;nbsp; And would the bolts always be all the same size as each other, and always the same size in different drawings?&amp;nbsp; Would they always all be on that same Layer?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 18:49:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219275#M288555</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-03-16T18:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219286#M288556</link>
      <description>&lt;P&gt;Explode them, then put a point in center of the arc, then replace point with block lisp (many on the internet)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/225135iB3C7A902DE5F7E7F/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="points.JPG" title="points.JPG" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 18:53:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219286#M288556</guid>
      <dc:creator>Patchy</dc:creator>
      <dc:date>2016-03-16T18:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219356#M288557</link>
      <description>&lt;P&gt;There are almost 800 of them!&lt;/P&gt;&lt;P&gt;Lots of houres to explode and extract center point of each one!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards Akmah&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 19:21:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219356#M288557</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-16T19:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219375#M288558</link>
      <description>&lt;P&gt;&lt;A href="http://autocadtips1.com/2012/03/27/autolisp-replace-selected-points-with-block/" target="_blank"&gt;http://autocadtips1.com/2012/03/27/autolisp-replace-selected-points-with-block/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 19:30:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219375#M288558</guid>
      <dc:creator>Patchy</dc:creator>
      <dc:date>2016-03-16T19:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219382#M288559</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/558015"&gt;@Patchy&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Explode them, then put a point in center of the arc, then replace point with block lisp....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Presumably a &lt;EM&gt;routine&lt;/EM&gt; is wanted to do this [otherwise you'd need to go around with CENter-Osnap and the Point command and try to catch all of them].&amp;nbsp; So if such a routine needs to find the center of each bolt anyway, it may as well just put the Block there directly, and avoid a bunch of intermediary Points.&amp;nbsp; [Or if you do it manually, Insert the Block once, then Copy it with the Multiple option and running CENter Osnap -- neither Exploding nor Points are needed.]&amp;nbsp; It would also make the deleting of the bolt Polylines easier for a routine to do, if they are left &lt;EM&gt;un&lt;/EM&gt;-Exploded.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 19:33:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219382#M288559</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-03-16T19:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219427#M288560</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is probably not a difficult thing to build a routine to do.&amp;nbsp;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For instance [very basic and tested all of &lt;EM&gt;once&lt;/EM&gt; in your sample drawing]:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)
(defun C:BoltSub (/ ss n bolt verts ctr)
  (setq ss (ssget "_X" '((0 . "LWPOLYLINE") (8 . "BULT") (90 . 2))))
  (repeat (setq n (sslength ss))
    (setq
      bolt (ssname ss (setq n (1- n)))
      verts (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget bolt))
      ctr (mapcar '/ (mapcar '+ (cdar verts) (cdadr verts)) '(2 2 2))
    ); setq
    (command "_.insert" "&lt;EM&gt;&lt;FONT color="#33cccc"&gt;YourBlockName&lt;/FONT&gt;&lt;/EM&gt;" "_none" ctr "" "" "")
    (entdel bolt)
  ); repeat
); defun&lt;/PRE&gt;
&lt;P&gt;Puts them on the current Layer, at a scale of 1 and rotation of 0.&amp;nbsp; Could be faster using (entmake) [in which case the 10 could be &lt;EM&gt;left in&lt;/EM&gt; the vertex entity-data entries, because that will be applicable to the insertion-point entry for the Block], could use the usual enhancements, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 19:55:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219427#M288560</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-03-16T19:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219448#M288561</link>
      <description>How did you place the point at the center of each exploded donuts?</description>
      <pubDate>Wed, 16 Mar 2016 20:02:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219448#M288561</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-16T20:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219454#M288562</link>
      <description>Basically the problem is to extract the center point and use it to insert the block. I never seen this donuts object before, the file must be an old drawing! when I explode them I get two arcs for every donuts and those can be joined together as a circle but only if I select two at a time ! So no select A and join is possible! But thanks anyway!</description>
      <pubDate>Wed, 16 Mar 2016 20:03:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219454#M288562</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-16T20:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219480#M288563</link>
      <description>&lt;P&gt;I used this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun c:Test (/ ss)&lt;BR /&gt;&amp;nbsp; (if (setq ss (ssget "_x" '((0 . "ARC"))))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((lambda (i / sn e)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (while (setq sn (ssname ss (setq i (1+ i))))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (entmakex (list '(0 . "POINT") (assoc 10 (setq e (entget sn)))(assoc 8 e)))))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (princ)&lt;BR /&gt;&amp;nbsp; )&lt;BR /&gt;&amp;nbsp; (princ)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 20:16:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219480#M288563</guid>
      <dc:creator>Patchy</dc:creator>
      <dc:date>2016-03-16T20:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219501#M288564</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;Basically the problem is to extract the center point and use it to insert the block. I never seen this donuts object before, the file must be an old drawing! when I explode them ....&lt;HR /&gt;....&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Donut is not an object type, it's a command which makes donut-shaped Polylines, and it's been around for ages and still is, so it may not be an old drawing, on that account.&amp;nbsp; But the fact that the one big coursing thing that looks like a Hatch pattern is a *X-named Block makes me think it's old, anyway -- it's been a &lt;EM&gt;mighty long time&lt;/EM&gt; since Hatch patterns were a special variety of Blocks, and weren't their own object type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know whether you tried the routine in Post 9 before&amp;nbsp;your Reply quoted here, but it does it without any Exploding or Points.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 20:24:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219501#M288564</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-03-16T20:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219548#M288565</link>
      <description>Thanks! I am going to try it tomorrow! Sure it will work! I been looking around this forum for over ten years! I am still looking for a function reading coordinates from an excel sheet in order to place blocks or other objects in a drawing. I know this is included in Civil 3D (takes time to master it!) but it should be a part of vanilla AutoCAD too! I run ArcGIS too and this function is ridiculously easy to use there. I made it first time I used it. Thank you all!</description>
      <pubDate>Wed, 16 Mar 2016 20:43:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219548#M288565</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-16T20:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing object with block lisp</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219554#M288566</link>
      <description />
      <pubDate>Wed, 16 Mar 2016 20:45:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/replacing-object-with-block-lisp/m-p/6219554#M288566</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-16T20:45:33Z</dc:date>
    </item>
  </channel>
</rss>

