<?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: Lisp to insert blocks on Polylines in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9007717#M84561</link>
    <description>&lt;P&gt;My attempt now i have more info. This will insert the block an the vertex closest to the mid point of the polyline. You will need to substitute the correct block name for "your block name".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:b2pl ( / *error* c_doc c_spc sv_lst sv_vals blk ss cnt l_obj len m_pt f_p d1 d2 i_pt)

  (defun *error* ( msg )
    (mapcar 'setvar sv_lst sv_vals)
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : " msg " occurred")))
    (princ)
  );end_defun

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        sv_lst (list 'cmdecho 'osmode)
        sv_vals (mapcar 'getvar sv_lst)
  );end_setq

  (mapcar 'setvar sv_lst '(0 0))

  (setq blk "YOUR BLOCK NAME"
        ss (ssget '((0 . "LWPOLYLINE")))
  );end_setq

  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq l_obj (vlax-ename-&amp;gt;vla-object (setq ent (ssname ss (setq cnt (1- cnt)))))
                  len (vlax-get-property l_obj 'length)
                  m_pt (vlax-curve-getpointatdist ent (/ len 2.0))
                  f_p (fix (vlax-curve-getparamatpoint ent m_pt))
                  d1 (vlax-curve-getpointatparam ent f_p)
                  d2 (vlax-curve-getpointatparam ent (1+ f_p))
            )
            (if (&amp;gt; (distance d1 m_pt) (distance m_pt d2)) (setq i_pt d2) (setq i_pt d1))
            (setq n_obj (vla-InsertBlock c_spc (vlax-3d-point i_pt) blk 1 1 1 0))
          );end_repeat
        )
        (t (alert "No Polylines Selected"))
  );end_cond

  (mapcar 'setvar sv_lst sv_vals)
  (princ)
);end_defun&lt;BR /&gt;(vl-load-com)&lt;/PRE&gt;</description>
    <pubDate>Thu, 05 Sep 2019 11:33:58 GMT</pubDate>
    <dc:creator>dlanorh</dc:creator>
    <dc:date>2019-09-05T11:33:58Z</dc:date>
    <item>
      <title>Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9005802#M84555</link>
      <description>&lt;P&gt;I'm looking for a lisp that can insert an attributed text block to polylines. Following are the conditions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a) Only one block shall be inserted to a polyline irrespective of its length&lt;/P&gt;&lt;P&gt;b) Block shall be inserted/snapped perfectly to anyone node along polyline&lt;/P&gt;&lt;P&gt;c) Blocks shall be inserted to multiple polylines in one go&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any help on this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Jaleel&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 14:11:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9005802#M84555</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-04T14:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9005866#M84556</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I'm looking for a lisp that can insert an attributed text block to polylines. Following are the conditions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a) Only one block shall be inserted to a polyline irrespective of its length&lt;/P&gt;&lt;P&gt;b) Block shall be inserted/snapped perfectly to anyone node along polyline&lt;/P&gt;&lt;P&gt;c) Blocks shall be inserted to multiple polylines in one go&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any help on this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Jaleel&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. What block? Upload a sample dwg containing the block&lt;/P&gt;&lt;P&gt;2. Polylines don't have nodes, they have vertices and segments. In multi vertex/segmented polylines, how do you decide which vertex/segment to choose when you are selecting via a selection set (i.e. default)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 14:40:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9005866#M84556</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2019-09-04T14:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9005872#M84557</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dlanorh is correct, the context of your request is very vague. More information is needed to assist you in a better way.&lt;/P&gt;&lt;P&gt;Without any more information, here is a sample of exactly what you are requesting (you need to change "MyBlockName" to your actual block name).&lt;/P&gt;&lt;PRE&gt;(defun c:BOP ( / ss osm cnt e)
&lt;FONT color="#FF9900"&gt;;Block On Polyline&lt;/FONT&gt;
(if (setq ss (ssget '((0 . "LWPOLYLINE"))))
  (progn
    (setq osm (getvar 'OSMODE)) (setvar 'OSMODE (logior 16384 osm))
    (setvar 'CMDECHO 0)
    (repeat (setq cnt (sslength ss))
      (setq e (entget (ssname ss (setq cnt (1- cnt)))))
      (command "-INSERT" "MyBlockName" "_scale" 1 "_none" (cdr (assoc 10 e)) 0)
    )&lt;FONT color="#33CCCC"&gt;;repeat&lt;/FONT&gt;
    (setvar 'OSMODE osm)
    (setvar 'CMDECHO 1)
  )&lt;FONT color="#33CCCC"&gt;;progn&lt;/FONT&gt;
&lt;FONT color="#33CCCC"&gt;;else&lt;/FONT&gt;
  (prompt "\n...no LWPOLYLINES found.")
)&lt;FONT color="#33CCCC"&gt;;if&lt;/FONT&gt;
(prompt "\nBOP Complete.")
(princ)
)&lt;FONT color="#33CCCC"&gt;;defun&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 14:43:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9005872#M84557</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2019-09-04T14:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9007113#M84558</link>
      <description>&lt;P&gt;Sorry for the confusion and thanks for this lisp.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This lisp works well, but only problem is it inserts block on endpoint. I need this to insert in any one of the middle vertice of polyline. In this case, all polylines have at least one middle vertice. Please refer to the attached screenshot for clarity. Appreciate if you can tweak the lisp to cater this specific need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Jaleel&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 05:17:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9007113#M84558</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-05T05:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9007589#M84559</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... I need this to insert in any one of the middle vertice of polyline. ….&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try replacing this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;" color="#000000"&gt;(command "-INSERT" "MyBlockName" "_scale" 1 "_none" (cdr (assoc 10 e)) 0)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;"&gt;with this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;" color="#000000"&gt;(command "_.INSERT"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;" color="#000000"&gt;&amp;nbsp; "MyBlockName" "_scale" 1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;" color="#000000"&gt;&amp;nbsp; "_none"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;"&gt;&amp;nbsp; &lt;FONT color="#0000ff"&gt;(vlax-curve-getPointAtParam e (fix (/ (vlax-curve-getEndParam e) 2)))&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;"&gt;&amp;nbsp; &lt;FONT color="#000000"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;" color="#000000"&gt;)&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 10:27:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9007589#M84559</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-09-05T10:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9007713#M84560</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;&amp;nbsp;wrote:
&lt;P class="1567682866489"&gt;&lt;SPAN style="font-family: inherit;"&gt;Try replacing this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;... and you may need to add this at the top or bottom of the file:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;(vl-load-com)&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 11:31:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9007713#M84560</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-09-05T11:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9007717#M84561</link>
      <description>&lt;P&gt;My attempt now i have more info. This will insert the block an the vertex closest to the mid point of the polyline. You will need to substitute the correct block name for "your block name".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:b2pl ( / *error* c_doc c_spc sv_lst sv_vals blk ss cnt l_obj len m_pt f_p d1 d2 i_pt)

  (defun *error* ( msg )
    (mapcar 'setvar sv_lst sv_vals)
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : " msg " occurred")))
    (princ)
  );end_defun

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        sv_lst (list 'cmdecho 'osmode)
        sv_vals (mapcar 'getvar sv_lst)
  );end_setq

  (mapcar 'setvar sv_lst '(0 0))

  (setq blk "YOUR BLOCK NAME"
        ss (ssget '((0 . "LWPOLYLINE")))
  );end_setq

  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq l_obj (vlax-ename-&amp;gt;vla-object (setq ent (ssname ss (setq cnt (1- cnt)))))
                  len (vlax-get-property l_obj 'length)
                  m_pt (vlax-curve-getpointatdist ent (/ len 2.0))
                  f_p (fix (vlax-curve-getparamatpoint ent m_pt))
                  d1 (vlax-curve-getpointatparam ent f_p)
                  d2 (vlax-curve-getpointatparam ent (1+ f_p))
            )
            (if (&amp;gt; (distance d1 m_pt) (distance m_pt d2)) (setq i_pt d2) (setq i_pt d1))
            (setq n_obj (vla-InsertBlock c_spc (vlax-3d-point i_pt) blk 1 1 1 0))
          );end_repeat
        )
        (t (alert "No Polylines Selected"))
  );end_cond

  (mapcar 'setvar sv_lst sv_vals)
  (princ)
);end_defun&lt;BR /&gt;(vl-load-com)&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Sep 2019 11:33:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9007717#M84561</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2019-09-05T11:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9008042#M84562</link>
      <description>&lt;P&gt;My suggestion in Message 5 will give you the middle vertex [or one of the two] in terms of the &lt;EM&gt;quantity of vertices&lt;/EM&gt;, which admittedly in some Polylines could be far from the &lt;EM&gt;middle of the overall length&lt;/EM&gt;&amp;nbsp;-- that's what Message 7 is designed to give you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just as a suggestion, a simpler way to do this much:&lt;/P&gt;
&lt;PRE&gt;....
            (setq l_obj (vlax-ename-&amp;gt;vla-object (setq ent (ssname ss (setq cnt (1- cnt)))))
                  len (vlax-get-property l_obj 'length)
                  m_pt (vlax-curve-getpointatdist ent (/ len 2.0))
                  f_p (fix (vlax-curve-getparamatpoint ent m_pt))
                  d1 (vlax-curve-getpointatparam ent f_p)
                  d2 (vlax-curve-getpointatparam ent (1+ f_p))
            )
            (if (&amp;gt; (distance d1 m_pt) (distance m_pt d2)) (setq i_pt d2) (setq i_pt d1))
....&lt;/PRE&gt;
&lt;P&gt;would be like this, getting the length by a way that doesn't require conversion to a VLA object [used for no other purpose], and using a common round-up-or-down approach [add 1/2 and &lt;FONT color="#000000"&gt;(fix)&lt;/FONT&gt; the result downward], thereby eliminating the need for the &lt;FONT color="#000000"&gt;l_obj&lt;/FONT&gt;, &lt;FONT color="#000000"&gt;d1&lt;/FONT&gt; and &lt;FONT color="#000000"&gt;d2&lt;/FONT&gt; variables and that &lt;FONT color="#000000"&gt;(if)&lt;/FONT&gt; test:&lt;/P&gt;
&lt;PRE&gt;....
    (setq
      ent (ssname ss (setq cnt (1- cnt)))
      len (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))
      m_pt (vlax-curve-getpointatdist ent (/ len 2))&lt;FONT color="#CC99FF"&gt;; 2 can be an integer, since len will be real&lt;/FONT&gt;
      i_pt (vlax-curve-getPointAtParam ent (fix (+ (vlax-curve-getparamatpoint ent m_pt) 0.5)))
    )
....
&lt;/PRE&gt;
&lt;P&gt;You &lt;EM&gt;could&lt;/EM&gt;&amp;nbsp; even eliminate the &lt;FONT color="#000000"&gt;len&lt;/FONT&gt; and &lt;FONT color="#000000"&gt;m_pt&lt;/FONT&gt; variables, too [they're used only once each, so you can instead just put their definitions in those places directly]:&lt;/P&gt;
&lt;PRE&gt;....
    (setq
      ent (ssname ss (setq cnt (1- cnt)))
      i_pt (vlax-curve-getPointAtParam ent (fix (+ (vlax-curve-getparamatpoint ent (vlax-curve-getpointatdist ent (/ (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)) 2))) 0.5)))
    ); setq
....&lt;/PRE&gt;
&lt;P&gt;Or, to break that long line down to see the relationships:&lt;/P&gt;
&lt;PRE&gt;....
    (setq
      ent
      (ssname ss (setq cnt (1- cnt)))
      i_pt
      (vlax-curve-getPointAtParam ent
        (fix
          (+
            (vlax-curve-getparamatpoint ent
              (vlax-curve-getpointatdist ent &lt;FONT color="#CC99FF"&gt;; what was m_pt&lt;/FONT&gt;
                (/ (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)) 2)&lt;FONT color="#CC99FF"&gt;; what was len&lt;/FONT&gt;
              )&lt;FONT color="#999999"&gt;; ...PointAtDist&lt;/FONT&gt;
            )&lt;FONT color="#999999"&gt;; ...ParamAtPoint&lt;/FONT&gt;
            0.5
          )&lt;FONT color="#999999"&gt;; +&lt;/FONT&gt;
        )&lt;FONT color="#999999"&gt;; fix&lt;/FONT&gt;
      )&lt;FONT color="#999999"&gt;; ...PointAtParam&lt;/FONT&gt;
    )&lt;FONT color="#999999"&gt;; setq&lt;/FONT&gt;
....&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Sep 2019 13:30:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9008042#M84562</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-09-05T13:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9008112#M84563</link>
      <description>&lt;P&gt;Sorry Kent, I just replied to the first post, and didn't re-read the thread.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm in total agreement, but I remember that when I started to learn, this kind of coding &lt;SPAN&gt;obfuscated&lt;/SPAN&gt; what was happening and was unintelligible. I try (not always successfully) to avoid this.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 13:57:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9008112#M84563</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2019-09-05T13:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9008544#M84564</link>
      <description>&lt;P&gt;To add to Kent's excellent critique, none of this is needed either:&lt;/P&gt;&lt;PRE&gt;(setq sv_lst  (list 'cmdecho 'osmode)
      sv_vals (mapcar 'getvar sv_lst)
)
;; ...
(mapcar 'setvar sv_lst '(0 0))
;; ...
(mapcar 'setvar sv_lst sv_vals)&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Sep 2019 16:52:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9008544#M84564</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2019-09-05T16:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9012507#M84565</link>
      <description>&lt;P&gt;Thank you all for your support. Above lisp I marked as solution worked perfectly in my case.&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Jaleel&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 09:40:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9012507#M84565</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-09-08T09:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9354439#M84566</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5644077"&gt;@dlanorh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;blocks at Polyline. it always place block at end ok lines. can you please fix it to place it in mid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks and best regards&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 05:50:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9354439#M84566</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-03T05:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9354925#M84567</link>
      <description>&lt;P&gt;Are you after something like this? It places a block at the mid point of an arc, line, polyline or spline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:bam ( / *error* c_doc c_spc sv_lst sv_vals blk sca ss cnt ent m_dst m_pt r_ang n_obj)

  (defun *error* ( msg )
    (mapcar 'setvar sv_lst sv_vals)
    (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : " msg " occurred.")))
    (princ)
  );end_*error*_defun

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_spc (vlax-get-property c_doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
        sv_lst (list 'osmode 'cmdecho)
        sv_vals (mapcar 'getvar sv_lst)
        blk "ARBLOCK"                   ;;BLOCK NAME TO INSERT
        sca 1                           ;;BLOCK SCALE
  );end_setq

  (mapcar 'setvar sv_lst '(0 0))

  (prompt "\nSelect Lines : ")
  (setq ss (ssget '((0 . "ARC,LINE,LWPOLYLINE,POLYLINE,SPLINE"))))
  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq ent (ssname ss (setq cnt (1- cnt)))
                  m_dst (/ (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) 2)
                  m_pt (vlax-curve-getpointatdist ent m_dst)
                  r_ang (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv ent (vlax-curve-getparamatpoint ent m_pt)))
                  n_obj (vlax-invoke c_spc 'insertblock m_pt blk sca sca sca r_ang)
            );end_setq
          );end_repeat
        )
  );end_cond
  (mapcar 'setvar sv_lst sv_vals)
  (princ)
);end_defun&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is difficult to understand exactly what you require. Perhaps attach a sample drawing showing before and after.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know the name of the block you want to insert, so you will have to change the commented line and insert the correct block name.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 10:23:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9354925#M84567</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2020-03-03T10:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9355276#M84568</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;blocks at Polyline. it always place block at end ok lines. can you please fix it to place it in mid.&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Will DIVIDE not do that for you?&amp;nbsp; Use the Block option, Divide into 2 segments.&amp;nbsp; No routine required.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 13:14:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9355276#M84568</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2020-03-03T13:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9357151#M84569</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5644077"&gt;@dlanorh&lt;/a&gt;&amp;nbsp;works very fine.. thats what i need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 09:08:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9357151#M84569</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-04T09:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to insert blocks on Polylines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9358139#M84570</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5644077"&gt;@dlanorh&lt;/a&gt;&amp;nbsp;&amp;nbsp;FWIW my 2c to add a bit of input error checking and removing unnecessary code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:bam (/ blk cnt c_spc ent m_dst m_pt n_obj r_ang sca ss)
  ;; Check that we have the block to insert
  (if (tblobjname "block" (setq blk "arblock"))
    (progn (setq c_spc (vlax-get-property
			 (vla-get-activedocument (vlax-get-acad-object))
			 (if (= 1 (getvar 'cvport))
			   'paperspace
			   'modelspace
			 )
		       )
		 sca   1.		; &amp;lt; - Block scale
	   )
	   (prompt "\nSelect ARC,LINE,*POLYLINE,SPLINE: ")
	   ;; Check for selection or (sslength nil) below will bomb
	   (if (setq ss (ssget '((0 . "ARC,LINE,*POLYLINE,SPLINE"))))
	     (repeat (setq cnt (sslength ss))
	       (setq ent   (ssname ss (setq cnt (1- cnt)))
		     m_dst (/ (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) 2)
		     m_pt  (vlax-curve-getpointatdist ent m_dst)
		     r_ang (angle '(0. 0. 0.)
				  (vlax-curve-getfirstderiv ent (vlax-curve-getparamatpoint ent m_pt))
			   )
		     n_obj (vlax-invoke c_spc 'insertblock m_pt blk sca sca sca r_ang)
	       )
	     )
	   )
    )
    (alert (strcat "\n" blk " needs to exist in drawing!"))
  )
  (princ)
)(vl-load-com)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 04 Mar 2020 15:16:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-insert-blocks-on-polylines/m-p/9358139#M84570</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2020-03-04T15:16:39Z</dc:date>
    </item>
  </channel>
</rss>

