<?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: Explode Circle in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explode-circle/m-p/6776780#M125302</link>
    <description>&lt;P&gt;Here's a routine -- &lt;STRONG&gt;SubDivide.lsp&lt;/STRONG&gt; with its &lt;STRONG&gt;SD&lt;/STRONG&gt; command -- that&amp;nbsp;I wrote about 5 years ago, that&amp;nbsp;will do that. &amp;nbsp;[I'd find the thread and post a link, but I've just updated it to work in newer versions --&amp;nbsp;the&amp;nbsp;original used (command) for Undo End in its *error* handler, which is now frowned upon.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not restricted to exploding Circles into Arcs, but&amp;nbsp;will do the same kind of subdividing-into-equal-parts to &lt;EM&gt;any&lt;/EM&gt; kind of finite-length&amp;nbsp;(vlax-curve)-class object with linearity -- Circle, Arc, Line, Polyline of any variety, Ellipse or&amp;nbsp;Spline, and in the last three cases, whether open or closed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And it has the option to specify a &lt;EM&gt;Maximum segment length&lt;/EM&gt;, rather than a specific number of segments, and it will calculate the minimum number of segments&amp;nbsp;to subdivide into, so that&amp;nbsp;each&amp;nbsp;is no more than the specified Maximum length.&amp;nbsp; It also &lt;EM&gt;remembers&lt;/EM&gt; the number of segments or Maximum length you asked for, and offers it as a default on subsequent use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It also uses a simpler way of determining whether an object's Layer is locked.&amp;nbsp; You don't need to get the Layer as an &lt;EM&gt;object&lt;/EM&gt; with (tblobjname), and then use (entget) on that object to get to&amp;nbsp;the 70-code entry that holds that information, but can get that more directly from&amp;nbsp;(tblsearch).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another little comment....&amp;nbsp; I hadn't started doing things as follows at the time, and didn't update the attached to do it this way, but I've taken to doing multiple System Variable value saving and resetting in a way that's related to but briefer than what you've done, though admittedly it takes &lt;EM&gt;two&lt;/EM&gt; variables instead of one to do it.&amp;nbsp;&amp;nbsp;Instead of doing this to save them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (setq vars (mapcar '(lambda (x)(cons x (getvar x))) '("cmdecho" "osmode")))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and this to turn them off:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (mapcar '(lambda (x)(setvar (car x) 0))&amp;nbsp; vars)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and this to reset them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (mapcar '(lambda (x)(setvar (car x)(cdr x))) vars)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've done this [for the same pair -- the list varies with different routines] to save them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (setq&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; svnames '(cmdecho osmode)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; svvals (mapcar 'getvar svnames)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and this to turn them off:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (mapcar 'setvar svnames '(0 0))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and this to reset them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (mapcar 'setvar svnames svvals)&lt;/P&gt;</description>
    <pubDate>Sat, 31 Dec 2016 05:37:57 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2016-12-31T05:37:57Z</dc:date>
    <item>
      <title>Explode Circle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explode-circle/m-p/6773816#M125300</link>
      <description>&lt;P&gt;My apologies. &amp;nbsp;I made fun in another thread about exploding circles.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To compensate (partially), I submit the following:&lt;/P&gt;&lt;P&gt;(It actually turns a circle into a specified number of arcs)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;;; ExplodeCircle.lsp written for fun by John F. Uhden (12-28-16)
;;
(defun c:ExplodeCircle (  / *error* vars ans n e ent dxf8 dxf10 dxf40 dang eang bang)
  (vl-load-com)
  (defun *error* (err)
    (mapcar '(lambda (x)(setvar (car x)(cdr x))) vars)
    (vla-endundomark *doc*)
    (cond
      ((not err))
      ((wcmatch (strcase err) "*CANCEL*,*QUIT*"))
      (1  (princ (strcat "\nERROR: " err)))
    )
    (princ)
  )
  (or *acad* (setq *acad* (vlax-get-acad-object)))
  (or *doc* (setq *doc* (vla-get-ActiveDocument *acad*)))
  (vla-endundomark *doc*)
  (vla-startundomark *doc*)
  (setq vars (mapcar '(lambda (x)(cons x (getvar x))) '("cmdecho" "osmode")))
  (mapcar '(lambda (x)(setvar (car x) 0)) vars)
  (command "_.expert" (getvar "expert")) ;; dummy command
  (while (not n)
    (initget 7)
    (setq ans (getint "\nEnter number of arcs to create: "))
    (if (= (type ans) 'INT)(setq n ans))
  )
  (while (setq e (car (entsel "\nSelect a circle to explode: ")))
    (and
      (setq ent (entget e))
      (or
        (= (cdr (assoc 0 ent)) "CIRCLE")
        (prompt "\nEntity selected is not a circle.")
      )
      (entdel e)
      (setq dxf8  (assoc 8 ent))
      (setq dxf10  (assoc 10 ent))
      (setq dxf40  (assoc 40 ent))
      (setq dang (/ pi n 0.5))
      (setq bang 0.0)
      (repeat n
        (setq eang (+ bang dang))
        (entmakex (list '(0 . "ARC") dxf8 dxf10 dxf40 (cons 50 bang)(cons 51 eang)))
        (setq bang eang)
      )
    )
  )
  (*error* nil)
)
(defun c:XC ()(c:ExplodeCircle))&lt;/PRE&gt;&lt;P&gt;I really have no use for it, but maybe it could be modified to be of some value (sorta like divide and break).&lt;/P&gt;&lt;P&gt;And, no, it doesn't check for locked layers. &amp;nbsp;Nor do you see anything happening.&lt;/P&gt;&lt;P&gt;Plus I should have used errmode so that a missed pick doesn't end it.&lt;/P&gt;&lt;P&gt;But that's all you should expect from an old fart.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 03:20:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explode-circle/m-p/6773816#M125300</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2016-12-29T03:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Explode Circle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explode-circle/m-p/6776625#M125301</link>
      <description>&lt;P&gt;This is an improved version.&lt;/P&gt;&lt;P&gt;It uses "errno" so you can miss a pick without it stopping.&lt;/P&gt;&lt;P&gt;It uses (sssetfirst) to highlight exploded circles.&lt;/P&gt;&lt;P&gt;Locked layers are notified.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;;; ExplodeCircle.lsp written for fun by John F. Uhden (12-28-16)
;; Improved (12-30-16)&lt;BR /&gt;;;
(defun c:ExplodeCircle (  / *error* vars ans n e ent Layer Ldata Flag dang eang bang ss)
  (vl-load-com)
  (defun *error* (err)
    (mapcar '(lambda (x)(setvar (car x)(cdr x))) vars)
    (sssetfirst)
    (vla-endundomark *doc*)
    (cond
      ((not err))
      ((wcmatch (strcase err) "*CANCEL*,*QUIT*"))
      (1  (princ (strcat "\nERROR: " err)))
    )
    (princ)
  )
  (or *acad* (setq *acad* (vlax-get-acad-object)))
  (or *doc* (setq *doc* (vla-get-ActiveDocument *acad*)))
  (vla-endundomark *doc*)
  (vla-startundomark *doc*)
  (setq vars (mapcar '(lambda (x)(cons x (getvar x))) '("cmdecho" "osmode")))
  (mapcar '(lambda (x)(setvar (car x) 0))  vars)
  (command "_.expert" (getvar "expert")) ;; dummy command
  (while (not n)
    (initget 7)
    (setq ans (getint "\nEnter number of arcs to create: "))
    (if (= (type ans) 'INT)(setq n ans))
  )
  (setq ss (ssadd))
  (setvar "errno" 0)
  (while (/= (getvar "errno") 52)
    (and
      (setq e (car (entsel "\nSelect a circle to explode: ")))
      (setq ent (entget e))
      (or
        (= (cdr (assoc 0 ent)) "CIRCLE")
        (prompt "\nEntity selected is not a circle.")
      )
      (setq Layer (cdr (assoc 8 ent)))
      (setq Ldata (tblobjname "layer" Layer))
      (setq Ldata (entget Ldata))
      (setq Flag (cdr (assoc 70 Ldata)))
      (if  (= (logand 4 Flag) 4)
        (prompt (strcat "\nLayer \"" Layer "\" is locked."))
        1
      )
      (entdel e)
      (setq dang (/ pi n 0.5))
      (setq bang 0.0)
      (repeat n
        (setq eang (+ bang dang))
        (ssadd
          (entmakex (list '(0 . "ARC") (assoc 8 ent) (assoc 10 ent) (assoc 40 ent) (cons 50 bang)(cons 51 eang)))
          ss
        )
        (sssetfirst nil ss)
        (setq bang eang)
      )
    )
  )
  (*error* nil)
)
(defun c:XC ()(c:ExplodeCircle))&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Dec 2016 23:22:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explode-circle/m-p/6776625#M125301</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2016-12-30T23:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Explode Circle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explode-circle/m-p/6776780#M125302</link>
      <description>&lt;P&gt;Here's a routine -- &lt;STRONG&gt;SubDivide.lsp&lt;/STRONG&gt; with its &lt;STRONG&gt;SD&lt;/STRONG&gt; command -- that&amp;nbsp;I wrote about 5 years ago, that&amp;nbsp;will do that. &amp;nbsp;[I'd find the thread and post a link, but I've just updated it to work in newer versions --&amp;nbsp;the&amp;nbsp;original used (command) for Undo End in its *error* handler, which is now frowned upon.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not restricted to exploding Circles into Arcs, but&amp;nbsp;will do the same kind of subdividing-into-equal-parts to &lt;EM&gt;any&lt;/EM&gt; kind of finite-length&amp;nbsp;(vlax-curve)-class object with linearity -- Circle, Arc, Line, Polyline of any variety, Ellipse or&amp;nbsp;Spline, and in the last three cases, whether open or closed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And it has the option to specify a &lt;EM&gt;Maximum segment length&lt;/EM&gt;, rather than a specific number of segments, and it will calculate the minimum number of segments&amp;nbsp;to subdivide into, so that&amp;nbsp;each&amp;nbsp;is no more than the specified Maximum length.&amp;nbsp; It also &lt;EM&gt;remembers&lt;/EM&gt; the number of segments or Maximum length you asked for, and offers it as a default on subsequent use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It also uses a simpler way of determining whether an object's Layer is locked.&amp;nbsp; You don't need to get the Layer as an &lt;EM&gt;object&lt;/EM&gt; with (tblobjname), and then use (entget) on that object to get to&amp;nbsp;the 70-code entry that holds that information, but can get that more directly from&amp;nbsp;(tblsearch).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another little comment....&amp;nbsp; I hadn't started doing things as follows at the time, and didn't update the attached to do it this way, but I've taken to doing multiple System Variable value saving and resetting in a way that's related to but briefer than what you've done, though admittedly it takes &lt;EM&gt;two&lt;/EM&gt; variables instead of one to do it.&amp;nbsp;&amp;nbsp;Instead of doing this to save them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (setq vars (mapcar '(lambda (x)(cons x (getvar x))) '("cmdecho" "osmode")))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and this to turn them off:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (mapcar '(lambda (x)(setvar (car x) 0))&amp;nbsp; vars)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and this to reset them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (mapcar '(lambda (x)(setvar (car x)(cdr x))) vars)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've done this [for the same pair -- the list varies with different routines] to save them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (setq&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; svnames '(cmdecho osmode)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; svvals (mapcar 'getvar svnames)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and this to turn them off:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (mapcar 'setvar svnames '(0 0))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and this to reset them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (mapcar 'setvar svnames svvals)&lt;/P&gt;</description>
      <pubDate>Sat, 31 Dec 2016 05:37:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explode-circle/m-p/6776780#M125302</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-12-31T05:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Explode Circle</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explode-circle/m-p/6777003#M125303</link>
      <description>&lt;P&gt;Kent: &amp;nbsp;Thank you for your input. &amp;nbsp;I am truly honored to have been outdone by you.&lt;/P&gt;</description>
      <pubDate>Sat, 31 Dec 2016 15:25:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/explode-circle/m-p/6777003#M125303</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2016-12-31T15:25:59Z</dc:date>
    </item>
  </channel>
</rss>

