<?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: Trin/Break line between two points in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5935823#M136149</link>
    <description>&lt;P&gt;Maybe like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:BreakatPoints ( / ensel)
  (while (setq ensel (entsel "\nSelect line or Polyline &amp;lt;quit&amp;gt;: "))
    (if (wcmatch (cdr (assoc 0 (entget (car ensel)))) "LINE,LWPOLYLINE,ARC")
      (command "_break" ensel "_F" PAUSE PAUSE)))
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;btw. some commands does not accept pure entity name but requires list of (&amp;lt;entname&amp;gt; selpoint) given by entsel. BREAK is one of them.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Dec 2015 09:32:59 GMT</pubDate>
    <dc:creator>ВeekeeCZ</dc:creator>
    <dc:date>2015-12-04T09:32:59Z</dc:date>
    <item>
      <title>Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5935778#M136148</link>
      <description>&lt;P&gt;I'm trying to create a simple lisp that breaks or trims a line or polyline between two picked points. I realise that a macro would do the same (^C^C_break \_f&amp;nbsp;) but I'd like to do it recursively. My code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:BreakatPoints ( / ent pt1 pt2)
    (while (setq ent (car(entsel "\nSelect line or Polyline ")))
	(if (wcmatch (cdr(assoc 0 (entget ent))) "LINE,LWPOLYLINE")
		  (progn
		  	(setq pt1 (getpoint "\nPick First Point"))
		  	(setq pt2 (getpoint "\nPick Second Point"))

			;; BREAK SELECTED LINE/POLYLINE BETWEEN pt1 &amp;amp; pt2

		  );;end progn
	  )
    )  ; while
  (princ)
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 08:42:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5935778#M136148</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-12-04T08:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5935823#M136149</link>
      <description>&lt;P&gt;Maybe like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:BreakatPoints ( / ensel)
  (while (setq ensel (entsel "\nSelect line or Polyline &amp;lt;quit&amp;gt;: "))
    (if (wcmatch (cdr (assoc 0 (entget (car ensel)))) "LINE,LWPOLYLINE,ARC")
      (command "_break" ensel "_F" PAUSE PAUSE)))
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;btw. some commands does not accept pure entity name but requires list of (&amp;lt;entname&amp;gt; selpoint) given by entsel. BREAK is one of them.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 09:32:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5935823#M136149</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2015-12-04T09:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5935860#M136150</link>
      <description>Works well, ta v much</description>
      <pubDate>Fri, 04 Dec 2015 10:07:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5935860#M136150</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-12-04T10:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5936050#M136151</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to create a simple lisp that breaks or trims a line or polyline between two picked points. I realise that a macro would do the same (^C^C_break \_f&amp;nbsp;) but I'd like to do it recursively. ....&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you aware of the &lt;EM&gt;&lt;STRONG&gt;automatic-repeat&lt;/STRONG&gt;&lt;/EM&gt; possibility in command macros?&amp;nbsp; Precede the double-cancel with an &lt;FONT color="#ff0000"&gt;asterisk&lt;/FONT&gt;, and it will recall itself continuously:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000" size="3"&gt;&lt;STRONG&gt;*&lt;/STRONG&gt;&lt;/FONT&gt;^C^C_break \_f&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've had that in menu items literally for decades, along with some related ones about breaking at a single point without needing to pick it twice.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 12:59:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5936050#M136151</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2015-12-04T12:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5938729#M136152</link>
      <description>&lt;P&gt;I didn't know that, nice tip Kent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Howver in this case I needed to turn osmode to 55, to select the break points, then reset osmode to the previous setting&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 08:36:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5938729#M136152</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-12-07T08:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5938996#M136153</link>
      <description>&lt;P&gt;First, look for similar solutions.&lt;/P&gt;&lt;P&gt;At google: autolisp break osnap.&lt;/P&gt;&lt;P&gt;One is at:&lt;/P&gt;&lt;P&gt;&lt;A href="http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-crossing-lines-using-lsp/td-p/2601882" target="_blank"&gt;http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/break-crossing-lines-using-lsp/td-p/2601882&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Many other exist.&lt;/P&gt;&lt;P&gt;IF you cannot find it the easy way,&lt;/P&gt;&lt;P&gt;post a messagee that indicates your actual problem in the&amp;nbsp; Subject .&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 12:20:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5938996#M136153</guid>
      <dc:creator>stevor</dc:creator>
      <dc:date>2015-12-07T12:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5939121#M136154</link>
      <description>Thanks Stevor, but BeekeeCZ has already found the solution, that's why it's marked as "Solved! by BeekeeCZ" in green</description>
      <pubDate>Mon, 07 Dec 2015 13:23:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5939121#M136154</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-12-07T13:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5939279#M136155</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;btw. some commands does not accept pure entity name but requires list of (&amp;lt;entname&amp;gt; selpoint) given by entsel. BREAK is one of them.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Actually, the Break command &lt;EM&gt;will&lt;/EM&gt; accept an entity name alone,&amp;nbsp;&lt;EM&gt;without&lt;/EM&gt; an associated selection point. &amp;nbsp;If you give it &lt;FONT color="#FF0000"&gt;only&amp;nbsp;an entity name&lt;/FONT&gt;, it jumps directly to&amp;nbsp;asking for a first point &lt;FONT color="#0000FF"&gt;&lt;EM&gt;without&lt;/EM&gt; your needing to ask for&amp;nbsp;the First-point option&lt;/FONT&gt;. &amp;nbsp;[This also works when done manually -- try &lt;STRONG&gt;BR&lt;/STRONG&gt;(eak) and then &lt;EM&gt;don't&lt;/EM&gt; pick anything, but just type &lt;STRONG&gt;L&lt;/STRONG&gt;(ast), assuming&amp;nbsp;the last-drawn object is Breakable, and you'll see.] &amp;nbsp;So you can do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:BreakatPoints ( / ensel)
  (while (setq ensel (entsel "\nSelect line or Polyline &amp;lt;quit&amp;gt;: "))
    (if (wcmatch (cdr (assoc 0 (entget (car ensel)))) "LINE,LWPOLYLINE,ARC")
      (command "_break" &lt;FONT color="#FF0000"&gt;(car ensel)&lt;/FONT&gt; PAUSE PAUSE)))&lt;FONT color="#FF0000"&gt;; entity name only&lt;FONT color="#000000"&gt;, and&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;&lt;EM&gt;without&lt;/EM&gt; "F"&lt;/FONT&gt;&lt;/FONT&gt;
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;which in this particular situation &lt;EM&gt;doesn't&lt;/EM&gt; really save you anything in terms of length of code, but in other circumstances it sometimes &lt;EM&gt;does&lt;/EM&gt; make more of a difference.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 14:38:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5939279#M136155</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2015-12-07T14:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5939392#M136156</link>
      <description>&lt;P&gt;Oooo. Shame on me!&amp;nbsp;Of course it's possible, and I've used that a couple of times! Somehow I focused on rewriting the macro...&lt;/P&gt;
&lt;P&gt;@Anonymous﻿&amp;nbsp;sorry that I have misled you.&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;thanks&amp;nbsp;for reminding me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@Anonymous﻿... in this case we can go back to your ent variable &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:BreakatPoints ( / ent)
  (while (setq ent (car (entsel "\nSelect an object to break: ")))
    (if (wcmatch (cdr (assoc 0 (entget ent))) "LINE,LWPOLYLINE,ARC")
      (command "_.break" ent PAUSE PAUSE)))
  (princ)
)&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Dec 2015 15:25:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5939392#M136156</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2015-12-07T15:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5939438#M136157</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;in this case I needed to turn osmode to 55, to select the break points, then reset osmode to the previous setting&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think that 55 as an OSMODE value has one unnecessary mode in it -- CENter. &amp;nbsp;With QUAdrant and MIDpoint and ENDpoint also included, I believe&amp;nbsp;one or another of those will &lt;EM&gt;always&lt;/EM&gt; be closer to the pick point than the CENter of an Arc or Circle or Polyline arc segment. &amp;nbsp;So I think 51 would be operationally identical [used in suggestions below].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You &lt;EM&gt;can&lt;/EM&gt; do that in a not-too-complicated&amp;nbsp;command macro, &lt;EM&gt;if&lt;/EM&gt; you always end its automatic repeating with &lt;EM&gt;ESCape when it's asking you to pick an object:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*^C^C(setq osm (getvar 'osmode)) _.break \'osmode 51 _first \\(setvar 'osmode osm)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you hit&amp;nbsp;&lt;EM&gt;Enter/Space&lt;/EM&gt; when it's asking you to pick an object, or if you cancel it after picking something but before having picked two break points, you will be left with the OSMODE value of 51&amp;nbsp;--&amp;nbsp;it won't reset whatever the value was before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To ensure that OSMODE&amp;nbsp;gets reset, &lt;EM&gt;no matter how&lt;/EM&gt; the User ends it, you would need a lot more code in an AutoLisp routine with *error* handling, rather than a command macro. &amp;nbsp;Here's a version that extends the allowable objects to &lt;EM&gt;all&lt;/EM&gt; [I think] Breakable types:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:BF (/ *error* osm esel ent etype)&lt;FONT color="#999999"&gt;; = Break with automatic First option&lt;/FONT&gt;
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    )&lt;FONT color="#999999"&gt;; if&lt;/FONT&gt;
    (setvar 'osmode osm)&lt;FONT color="#00CCFF"&gt;; reset&lt;/FONT&gt;
    (princ)
  )&lt;FONT color="#999999"&gt;; defun - *error*&lt;/FONT&gt;
  (setq osm (getvar 'osmode))
  (setvar 'osmode 51)
  (while (setq esel (entsel "\nSelect object for First-point Break &amp;lt;exit&amp;gt;: "))
    (setq
      ent (car esel)
      etype (cdr (assoc 0 (entget ent)))
    )&lt;FONT color="#999999"&gt;; setq&lt;/FONT&gt;
    (if
      (and
        (wcmatch etype "*LINE,ARC,CIRCLE,ELLIPSE,RAY,TRACE")
          &lt;FONT color="#00CCFF"&gt;; *&lt;FONT color="#3366FF"&gt;LINE&lt;/FONT&gt; accepts &lt;FONT color="#3366FF"&gt;Line&lt;/FONT&gt;, &lt;EM&gt;any&lt;/EM&gt; kind of Poly&lt;FONT color="#3366FF"&gt;line&lt;/FONT&gt;, Sp&lt;FONT color="#3366FF"&gt;line&lt;/FONT&gt;, and X&lt;FONT color="#3366FF"&gt;line&lt;/FONT&gt;, but we must disallow:&lt;/FONT&gt;
        (/= etype "M&lt;FONT color="#3366FF"&gt;LINE&lt;/FONT&gt;")&lt;FONT color="#00CCFF"&gt;; can't be Broken&lt;/FONT&gt;
      )&lt;FONT color="#999999"&gt;; and&lt;/FONT&gt;
      (command "_break" ent pause pause)&lt;FONT color="#999999"&gt;; then&lt;/FONT&gt;
      (prompt "\nCannot Break that object.")&lt;FONT color="#999999"&gt;; else&lt;/FONT&gt;
    )&lt;FONT color="#999999"&gt;; if&lt;/FONT&gt;
  )&lt;FONT color="#999999"&gt;; while&lt;/FONT&gt;
  (setvar 'osmode osm)&lt;FONT color="#00CCFF"&gt;; reset&lt;/FONT&gt;
  (princ)
)&lt;FONT color="#999999"&gt;; defun&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;It could be done with (ssget) and object-type selection filtering, but that always provides its own "Select objects: " prompt, always in the &lt;EM&gt;plural&lt;/EM&gt;, and without the opportunity to display the &amp;lt;exit&amp;gt; default, so I prefer the (entsel) approach in this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One other little advantage that has over the command macro approach is that it changes OSMODE only &lt;EM&gt;once&lt;/EM&gt;, and resets it only &lt;EM&gt;once&lt;/EM&gt;, surrounding the entire &lt;EM&gt;series&lt;/EM&gt; of however many Breaks the User does, rather than changing and resetting it separately for &lt;EM&gt;every&lt;/EM&gt; Break.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: &amp;nbsp;Another little feature that could be added would be for it to ask the User to select something again if they &lt;EM&gt;miss&lt;/EM&gt; in trying to pick something, rather than ending it. &amp;nbsp;As it is, you have the choice to end it by picking where there's nothing, which you may prefer, but if you &lt;EM&gt;meant&lt;/EM&gt; to pick something and missed, it will exit the command -- write back if you'd like to know how to be prompted to pick again instead [and can't figure it out for yourself].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 15:47:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5939438#M136157</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2015-12-07T15:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5939787#M136158</link>
      <description>&lt;P&gt;Thanks Kent, that looks a little more thorough.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd prefer ensel to ssget, I'm only selecting one item (usually a line) at a time.&amp;nbsp;It's not a task which requires doing many times in any given drawing, nevertheless it's quite irritating typing in characters many times per day (in different drawings). Although thinking about it I could have used:&lt;/P&gt;&lt;PRE&gt;(ssget "_+.:E:S" '((0 . "LINE,LWPOLYLINE,ARC,CIRCLE,ELLIPSE,RAY"))))&lt;/PRE&gt;&lt;P&gt;But to no real advantage&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for propting if the item is mis-picked I guess a simple 'if' statement&lt;/P&gt;&lt;PRE&gt;while (if(setq esel&lt;/PRE&gt;&lt;P&gt;Would work with something like 'Missed, try again' as an else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS I only suggested OSMODE 55 because it's my default setting for Object Snap on. I was too lazy to find the more appropriate setting of 51 !!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 18:27:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5939787#M136158</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-12-07T18:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5940040#M136159</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for propting if the item is mis-picked I guess a simple 'if' statement&lt;/P&gt;
&lt;PRE&gt;while (if(setq esel&lt;/PRE&gt;
&lt;P&gt;Would work with something like 'Missed, try again' as an else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
....&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That approach would also &lt;EM&gt;not&lt;/EM&gt; give you a viable&amp;nbsp;&amp;lt;exit&amp;gt; default option, because whether you miss or hit Enter/space, it's going to return nil, so it will ask you to try again, and&amp;nbsp;the only way out is ESCape. &amp;nbsp;To have a routine &lt;EM&gt;distinguish between a missed pick and Enter&lt;/EM&gt;, so it can ask you to pick again if you miss but will exit the routine if you hit Enter, you need to make use of the ERRNO System Variable. &amp;nbsp;Do a Search for &lt;STRONG&gt;errno&lt;/STRONG&gt; and you'll find a lot of routines that use it for just that kind of purpose.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 19:42:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5940040#M136159</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2015-12-07T19:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5940826#M136160</link>
      <description>&lt;P&gt;I'm not sure if I've got the right code within 't cond ' but this seems to work:&lt;/P&gt;&lt;PRE&gt;(defun C:BF (/ *error* osm esel ent etype); = Break with automatic First option
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    ); if
    (setvar 'osmode osm); get current osnap setting &amp;amp; store it
    (princ)
  ); defun - *error*
  (setq osm (getvar 'osmode))
  (setvar 'osmode 51)  
  (while
	(progn
	  (setvar 'errno 0)
    		(setq esel (entsel "\nSelect object for First-point Break &amp;lt;exit&amp;gt;: "))
	  (cond
	    ((= 7 (getvar 'errno))(princ "\nNothing Selected - try again."))
                ((null esel) nil)
	    (t
	     (progn
		 (setq
		      ent (car esel)
		      etype (cdr (assoc 0 (entget ent)))
		 ); setq
		    (if
		      (and
		        (wcmatch etype "*LINE,ARC,CIRCLE,ELLIPSE,RAY,TRACE"); *LINE accepts Line, any kind of Polyline, Spline, and Xline, but we must disallow multilines
		        (/= etype "MLINE"); can't be Broken
		      ); and
		      (command "_break" ent pause pause); then
		      (prompt "\nCannot Break that object."); else
		    ); if
	 	)
	     t); end cond t
	);; end cond
    );; progn
  ); while  
  (setvar 'osmode osm); reset
  (setvar 'errno 2); reset to default setting
  (princ)
); defun&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Dec 2015 07:15:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5940826#M136160</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-12-08T07:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Trin/Break line between two points</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5941617#M136161</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;I'm not sure if I've got the right code within 't cond ' but this seems to work:&lt;/P&gt;
&lt;PRE&gt;....  
  (while
	&lt;FONT color="#993366"&gt;(progn&lt;/FONT&gt;
	  (setvar 'errno 0)
    		(setq esel (entsel "\nSelect object for First-point Break &amp;lt;exit&amp;gt;: "))
	  (cond
	    ((= 7 (getvar 'errno))(princ "\nNothing Selected - try again."))
                &lt;FONT color="#FF00FF"&gt;((null esel) nil)&lt;/FONT&gt;
	    (t
	     (progn
....&lt;BR /&gt;		    &lt;FONT color="#FF0000"&gt;(if&lt;/FONT&gt;
		      (and
		        (wcmatch etype "*LINE,ARC,CIRCLE,ELLIPSE,RAY,TRACE"); *LINE accepts Line, any kind of Polyline, Spline, and Xline, but we must disallow multilines
		        (/= etype "MLINE"); can't be Broken
		      ); and
		      (command "_break" ent pause pause); then
		      (prompt "\nCannot Break that object."); else
		    &lt;FONT color="#FF0000"&gt;)&lt;/FONT&gt;; if
	 	)
	     &lt;FONT color="#008000"&gt;t&lt;/FONT&gt;); end cond t
	);; end cond
    &lt;FONT color="#993366"&gt;)&lt;/FONT&gt;;; progn
  ); while  
....
  &lt;FONT color="#3366FF"&gt;(setvar 'errno 2); reset to default setting&lt;/FONT&gt;
  (princ)
); defun&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That may be viable, though it's a little peculiar in a few ways. &amp;nbsp;Typically, a (while) function's first argument is some kind of &lt;EM&gt;test&lt;/EM&gt;, and if the test does not return nil, then there's something following for it to do before going back and running that test again. &amp;nbsp;The way you have it, the &lt;FONT color="#993366"&gt;(progn)&lt;/FONT&gt; that is the "test" is not &lt;EM&gt;followed&lt;/EM&gt; by anything for it to do, but in the right circumstances contains the thing to do &lt;EM&gt;within&lt;/EM&gt; it. &amp;nbsp;It returns nil [from the &lt;FONT color="#FF00FF"&gt;((null esel) nil)&lt;/FONT&gt; part]&amp;nbsp;and stops the loop if they hit Enter, but it's not &lt;EM&gt;testing the value of ERRNO&lt;/EM&gt; to come to that determination, as it is in other conditions. &amp;nbsp;And the T condition in which it goes ahead and Breaks the object [if Breakable] is forced to have &lt;FONT color="#008000"&gt;&lt;EM&gt;another&lt;/EM&gt; T&lt;/FONT&gt; added at the end just to keep the (while) loop going for another selection [without it, the (command) function in there would return nil and stop the loop]. &amp;nbsp;You can avoid that extraneous element, and also eliminate having an&amp;nbsp;&lt;FONT color="#FF0000"&gt;(if)&lt;/FONT&gt;&amp;nbsp;function&amp;nbsp;&lt;EM&gt;nested inside&lt;/EM&gt; one of the (cond) conditions [one of the main benefits of (cond) is that it eliminates&amp;nbsp;nested (if) functions], by structuring it differently. &amp;nbsp;[Also, there is &lt;FONT color="#3366FF"&gt;no "default" value for ERRNO&lt;/FONT&gt; to be reset to, but an "initial" value of 0, and its value is changing all the time as you do things, so there's no point in resetting it explicitly -- anything you set it to will soon be overridden anyway.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's one way [certainly not the only way] to do this kind of thing, that I have sometimes used:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:BF (/ *error* osm esel ent &lt;FONT color="#339966"&gt;edata&lt;/FONT&gt; etype done)
; = Break with automatic First option
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    ); if
    (setvar 'osmode osm); get current osnap setting &amp;amp; store it
    (princ)
  ); defun - *error*
  (setq osm (getvar 'osmode))
  (setvar 'osmode 51)  
  (while (not &lt;FONT color="#993300"&gt;done&lt;/FONT&gt;)&lt;FONT color="#00CCFF"&gt;; check that User hasn't chosen &amp;lt;exit&amp;gt; default&lt;/FONT&gt;
    (setvar 'errno 0)
    (setq esel (entsel "\nSelect object for First-point Break &amp;lt;exit&amp;gt;: "))
    (cond
      ( (and ; selection of Breakable &amp;amp; unlocked object
          (= (getvar 'errno) 0)&lt;FONT color="#00CCFF"&gt;; picked something&lt;/FONT&gt;
          (setq ent (car esel) &lt;FONT color="#008000"&gt;edata (entget ent)&lt;/FONT&gt; etype (cdr (assoc 0 &lt;FONT color="#008000"&gt;edata&lt;/FONT&gt;)))
          (wcmatch etype "*LINE,ARC,CIRCLE,ELLIPSE,RAY,TRACE")
            &lt;FONT color="#00CCFF"&gt;; *LINE = Line/any kind of Polyline/Spline/Xline, but must disallow:&lt;/FONT&gt;
          (/= etype "MLINE")&lt;FONT color="#00CCFF"&gt;; can't be Broken&lt;/FONT&gt;
          &lt;FONT color="#0000FF"&gt;(= (logand 4 (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 &lt;/FONT&gt;&lt;FONT color="#008000"&gt;edata&lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;)))))) 0)&lt;/FONT&gt;
            &lt;FONT color="#00CCFF"&gt;; 0 = Unlocked Layer, 4 = Locked&lt;/FONT&gt;
        ); and
        (command "_break" ent pause pause); proceed!
      ); Breakable-object selection condition
      ((= (getvar 'errno) 7) (prompt "\nNothing Selected - try again."))&lt;FONT color="#00CCFF"&gt;; missed&lt;/FONT&gt;
      ((= (getvar 'errno) 52) &lt;FONT color="#993300"&gt;(setq done T)&lt;/FONT&gt;)&lt;FONT color="#00CCFF"&gt;; Enter/space at Selection prompt stops loop&lt;/FONT&gt;
      ((prompt "\nNot a Breakable object, &lt;FONT color="#0000FF"&gt;or on a locked Layer&lt;/FONT&gt; --"))&lt;BR /&gt;        &lt;FONT color="#00CCFF"&gt;; none of the above [failed some test(s) in first condition, didn't meet others]&lt;/FONT&gt;
    )&lt;FONT color="#999999"&gt;; cond&lt;/FONT&gt;
  )&lt;FONT color="#999999"&gt;; while&lt;/FONT&gt;
  (setvar 'osmode osm); reset
  (princ)
); defun&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I added the &lt;FONT color="#0000FF"&gt;locked-Layer check&lt;/FONT&gt;, and in order to facilitate checking both that and&amp;nbsp;the entity type, the &lt;FONT color="#339966"&gt;edata&lt;/FONT&gt; variable, and the &lt;FONT color="#993300"&gt;done&lt;/FONT&gt; variable to end it on Enter/space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[The fallback-condition &amp;nbsp;((prompt ... &amp;nbsp;part&amp;nbsp;could be done: (&lt;STRONG&gt;T&lt;/STRONG&gt; (prompt ... , but the T is not needed when there's only one thing for it to do.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another variant would be to eliminate the condition for ERRNO being 7, and change the fallback-condition prompt to the more all-encompassing&amp;nbsp;"\nNothing selected, or&amp;nbsp;not a Breakable object, or on a locked Layer&amp;nbsp;- try again." &amp;nbsp;Conversely, it could pull those all apart and have &lt;EM&gt;separate&lt;/EM&gt; prompts for each of&amp;nbsp;the individual no-go situations.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2015 15:14:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trin-break-line-between-two-points/m-p/5941617#M136161</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2015-12-08T15:14:27Z</dc:date>
    </item>
  </channel>
</rss>

