<?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 Break a line with a preset specified distance in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-a-line-with-a-preset-specified-distance/m-p/6348622#M131902</link>
    <description>&lt;P&gt;I am new to AutoLISP so please bare with me. I have to create a .001" break in either the middle of a line or at a specified pick point. can anyone help me make a lsp function to do this. I have tried to write it myself and I get to the point of having the function pick the middle of the line but I can't seem to get it to put the .001 gap in....it breaks the line but without the .001 gap. I need this to work horizontal, vertical and diagonal lines&lt;/P&gt;</description>
    <pubDate>Wed, 25 May 2016 15:02:50 GMT</pubDate>
    <dc:creator>They_Call_Me_Jake</dc:creator>
    <dc:date>2016-05-25T15:02:50Z</dc:date>
    <item>
      <title>Break a line with a preset specified distance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-a-line-with-a-preset-specified-distance/m-p/6348622#M131902</link>
      <description>&lt;P&gt;I am new to AutoLISP so please bare with me. I have to create a .001" break in either the middle of a line or at a specified pick point. can anyone help me make a lsp function to do this. I have tried to write it myself and I get to the point of having the function pick the middle of the line but I can't seem to get it to put the .001 gap in....it breaks the line but without the .001 gap. I need this to work horizontal, vertical and diagonal lines&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 15:02:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-a-line-with-a-preset-specified-distance/m-p/6348622#M131902</guid>
      <dc:creator>They_Call_Me_Jake</dc:creator>
      <dc:date>2016-05-25T15:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Break a line with a preset specified distance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-a-line-with-a-preset-specified-distance/m-p/6349047#M131903</link>
      <description>&lt;P&gt;Break at midpoint&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun C:test (/ tol b e p1 p2 a d l)
  (if
    (setq tol 0.001
          b (/ tol 2.0)
          e (car (entsel "\nPick a line to break at mid point: "))
          p1 (cdr (assoc 10 (entget e)))
          p2 (cdr (assoc 11 (entget e)))
          a (angle p1 p2)
          d (- (/ (distance p1 p2) 2) b)
          l (cdr (assoc 8 (entget e)))
    )
    (progn
      (entmake (list (cons 0 "LINE") (cons 8 l) (cons 10 p1) (cons 11 (polar p1 a d))))
      (entmake (list (cons 0 "LINE") (cons 8 l) (cons 10 (polar p1  a (+ d tol))) (cons 11 p2)))
      (entdel e)
    )
  )
)  &lt;/PRE&gt;&lt;P&gt;Break at specified distance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun C:test2 (/ tol b e p p1 p2 l)
  (if
    (setq tol 0.001
          b (/ tol 2.0)
          e (entsel "\nPick a line to break: ") 
          p (vlax-curve-getClosestpointTo (vlax-ename-&amp;gt;vla-object (car e)) (cadr e) nil)
          p1 (cdr (assoc 10 (entget (car e))))
          p2 (cdr (assoc 11 (entget (car e))))
          l (cdr (assoc 8 (entget (car e))))
    )
    (progn
      (entmake (list (cons 0 "LINE") (cons 8 l) (cons 10 (polar p (angle p p1) b)) (cons 11 p1)))
      (entmake (list (cons 0 "LINE") (cons 8 l) (cons 10 (polar p (angle p p2) b)) (cons 11 p2)))
      (entdel (car e))
    )
  )
)&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 May 2016 17:59:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-a-line-with-a-preset-specified-distance/m-p/6349047#M131903</guid>
      <dc:creator>jdiala</dc:creator>
      <dc:date>2016-05-25T17:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Break a line with a preset specified distance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-a-line-with-a-preset-specified-distance/m-p/6349079#M131904</link>
      <description>forgot the (vl-load-com)</description>
      <pubDate>Wed, 25 May 2016 18:12:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-a-line-with-a-preset-specified-distance/m-p/6349079#M131904</guid>
      <dc:creator>jdiala</dc:creator>
      <dc:date>2016-05-25T18:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Break a line with a preset specified distance</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-a-line-with-a-preset-specified-distance/m-p/6350956#M131905</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@mrsmithTYTMZ wrote:&lt;BR /&gt;
&lt;P&gt;I am new to AutoLISP so please bare with me. I have to create a .001" break in either the middle of a line or at a specified pick point.&amp;nbsp;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;[Do I have to take my clothes off? &amp;nbsp;(The word you want is&amp;nbsp;"&lt;EM&gt;bear&lt;/EM&gt; with me.")]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about some that are &lt;EM&gt;not restricted&lt;/EM&gt; to Line objects? &amp;nbsp;The following &lt;STRONG&gt;Gap001M&lt;/STRONG&gt; [for a &lt;STRONG&gt;Gap&lt;/STRONG&gt; of &lt;STRONG&gt;.001&lt;/STRONG&gt; at the &lt;STRONG&gt;M&lt;/STRONG&gt;idpoint] and &lt;STRONG&gt;Gap001S&lt;/STRONG&gt; [for the gap at the &lt;STRONG&gt;S&lt;/STRONG&gt;election point] will do it to&amp;nbsp;&lt;EM&gt;Lines, Arcs, Circles, Polylines&lt;/EM&gt; [any variety, at line or arc segments], &lt;EM&gt;Ellipses, Splines,&lt;/EM&gt; and [in only the at-the-selection-point one] &lt;EM&gt;Xlines and Rays.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could still use the usual enhancements [error handler, Undo begin/end wrapping, etc.], but see what you think.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use Gap001&lt;STRONG&gt;M&lt;/STRONG&gt; on a Polyline, it puts the gap in the middle of its &lt;EM&gt;overall&lt;/EM&gt; length, but it could be altered to do it at the middle of the &lt;EM&gt;segment&lt;/EM&gt; in which you pick it, if desired. &amp;nbsp;It could also be altered to a&lt;EM&gt;sk for a&amp;nbsp;Gap size&lt;/EM&gt;, including a default, so you wouldn't need separate ones for different sizes. &amp;nbsp;And it could be altered to operate repeatedly as long as continue to pick objects, and/or for Gap001M, to let you select as many objects as you want all at once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun GetForGap (subpr / edata etype)
  (and
    (setq esel (entsel (strcat "\nSelect object to make gap at " subpr "point: ")))
    (setq ent (car esel) edata (entget ent) etype (cdr (assoc 0 edata)))
    (wcmatch etype "*LINE,ARC,CIRCLE,ELLIPSE,RAY")
    (/= etype "MLINE"); accepted by above, but not by (vlax-curve...)
    (if (= subpr "mid") (not (wcmatch etype "XLINE,RAY")) T)
      ; allow only in Gap001S [can't calculate midpoint]
    (= (logand (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 edata))))) 4) 0); unlocked
  ); and
); defun -- GetForGap

(defun Gap001 (loc / osm cir)
  (setq osm (getvar 'osmode))
  (setvar 'osmode 0)
  (command
    "_.circle" loc 0.0005
    "_.zoom" (polar loc 0 0.001) (polar loc pi 0.001)
    "_.regen" ; [because Trim pick at 'loc' can miss if curve is segmented]
    "_.trim" (setq cir (entlast)) "" loc ""
    "_.erase" cir ""
    "_.zoom" "_previous"
  ); command
  (setvar 'osmode osm)
); defun -- Gap001

(defun C:Gap001M (/ esel ent)
  (if (GetForGap "mid")
    (Gap001 ; then
      (vlax-curve-getPointAtDist ent
        (/ (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)) 2)
      ); ...getPoint...
    ); Gap001
    (prompt "\nNothing selected, not a viable object, or on a locked Layer."); else
  ); if
  (princ)
); defun -- C:Gap001M

(defun C:Gap001S (/ esel ent)
  (if (GetForGap "selection ")
    (Gap001 (osnap (cadr esel) "_nea")); then
    (prompt "\nNothing selected, not a viable object, or on a locked Layer."); else
  ); if
  (princ)
); defun -- C:Gap001S&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 May 2016 17:23:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-a-line-with-a-preset-specified-distance/m-p/6350956#M131905</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-05-26T17:23:38Z</dc:date>
    </item>
  </channel>
</rss>

