<?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 Drawing arcs with autolisp in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5514931#M143666</link>
    <description>&lt;P&gt;I think I might be forgetting to reset something.&lt;/P&gt;&lt;P&gt;I have created the following program to illustrate my issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun C:myTestProg()
      (setq flatLength 3)
      (setq arcHeight 5)
      (setq flatLeft (list (* -1 (/ flatLength 2)) 0))
      (setq flatRight (list (/ flatLength 2) 0))
      (setq arcTop (list 0 arcHeight))
      (command "line" flatLeft flatRight "")
      (command "arc" flatRight arcTop flatLeft)
      (princ)
)&lt;/PRE&gt;&lt;P&gt;If I run this in the commandline of autocad 2012 I get a line&amp;nbsp;from (-1.5,0)&amp;nbsp;to (1.5,0) and an arc&amp;nbsp;between these points and through (0,5).&lt;/P&gt;&lt;P&gt;However,&amp;nbsp;if I immediately repeat the program I get the same line, but an arc between those two points and through (0,2.4).&lt;/P&gt;&lt;P&gt;Repeating a third time or more&amp;nbsp;gives the same line and arc through (0,2.4).&lt;/P&gt;&lt;P&gt;Am I not terminating the arc command correctly? I get an error if I add "" to the end.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Eric&lt;/P&gt;</description>
    <pubDate>Fri, 20 Feb 2015 18:39:51 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-02-20T18:39:51Z</dc:date>
    <item>
      <title>Drawing arcs with autolisp</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5514931#M143666</link>
      <description>&lt;P&gt;I think I might be forgetting to reset something.&lt;/P&gt;&lt;P&gt;I have created the following program to illustrate my issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun C:myTestProg()
      (setq flatLength 3)
      (setq arcHeight 5)
      (setq flatLeft (list (* -1 (/ flatLength 2)) 0))
      (setq flatRight (list (/ flatLength 2) 0))
      (setq arcTop (list 0 arcHeight))
      (command "line" flatLeft flatRight "")
      (command "arc" flatRight arcTop flatLeft)
      (princ)
)&lt;/PRE&gt;&lt;P&gt;If I run this in the commandline of autocad 2012 I get a line&amp;nbsp;from (-1.5,0)&amp;nbsp;to (1.5,0) and an arc&amp;nbsp;between these points and through (0,5).&lt;/P&gt;&lt;P&gt;However,&amp;nbsp;if I immediately repeat the program I get the same line, but an arc between those two points and through (0,2.4).&lt;/P&gt;&lt;P&gt;Repeating a third time or more&amp;nbsp;gives the same line and arc through (0,2.4).&lt;/P&gt;&lt;P&gt;Am I not terminating the arc command correctly? I get an error if I add "" to the end.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Eric&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 18:39:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5514931#M143666</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-02-20T18:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing arcs with autolisp</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5514966#M143667</link>
      <description>&lt;P&gt;Hi Eric,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using command function, we need to &lt;SPAN class="hps"&gt;ensure that&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;there is no&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;interference&lt;/SPAN&gt; from object snap modes....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;(defun C:myTestProg()
  (setq flatLength 3)
  (setq arcHeight 5)
  (setq flatLeft (list (* -1 (/ flatLength 2)) 0))
  (setq flatRight (list (/ flatLength 2) 0))
  (setq arcTop (list 0 arcHeight))
  (command "line" "_NONE" flatLeft "_NONE" flatRight "")
  (command "arc" "_NONE" flatRight "_NONE" arcTop "_NONE" flatLeft)
  (princ)
)

;; or

(defun C:myTestProg()
  (setq osm (getvar 'OSMODE))
  (setvar 'OSMODE 0)
  (setq flatLength 3)
  (setq arcHeight 5)
  (setq flatLeft (list (* -1 (/ flatLength 2)) 0))
  (setq flatRight (list (/ flatLength 2) 0))
  (setq arcTop (list 0 arcHeight))
  (command "line" flatLeft flatRight "")
  (command "arc" flatRight arcTop flatLeft)
  (setvar 'OSMODE osm)
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, &lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 19:00:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5514966#M143667</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-02-20T19:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing arcs with autolisp</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5514982#M143668</link>
      <description>&lt;P&gt;Perfect, works like a charm!&lt;/P&gt;&lt;P&gt;Thanks Henrique&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 19:09:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5514982#M143668</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-02-20T19:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing arcs with autolisp</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5514987#M143669</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Perfect, works like a charm!&lt;/P&gt;
&lt;P&gt;Thanks Henrique&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You're welcome, Eric!&lt;BR /&gt;Glad I could help&lt;BR /&gt;&lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 19:12:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5514987#M143669</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-02-20T19:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing arcs with autolisp</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5515536#M143670</link>
      <description>&lt;P&gt;Be careful with division of integers, since:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE style="max-height: 500px; white-space: pre; border: 1px solid #417394; overflow: auto; background: #f2f6f8; color: #222; padding: 3px; line-height: 120%;"&gt;_$ (/ 3 2)
1&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whereas, using reals (doubles) yields:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE style="max-height: 500px; white-space: pre; border: 1px solid #417394; overflow: auto; background: #f2f6f8; color: #222; padding: 3px; line-height: 120%;"&gt;_$ (/ 3.0 2.0)
1.5&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an alternative to calling standard AutoCAD commands, you could also use &lt;FONT color="#0000FF"&gt;entmake&lt;/FONT&gt; to add the entity DXF data directly to the drawing database and cut out the 'middle man' - consequently, this method is much faster and is not affected by Object Snap:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE style="max-height: 500px; white-space: pre; border: 1px solid #417394; overflow: auto; background: #f2f6f8; color: #222; padding: 3px; line-height: 120%;"&gt;(defun c:mytestprog ( / flatlength archeight flatleft flatright lst )
    (setq flatlength 3.0
          archeight  5.0
          flatleft   (list (/ flatlength -2.0) 0)
          flatright  (list (/ flatlength  2.0) 0)
    )
    (entmake
        (list
           '(0 . "LINE")
            (cons 10 flatleft)
            (cons 11 flatright)
        )
    )
    (if (setq lst (LM:3PArc flatright (list 0 archeight) flatleft))
        (entmake
            (cons '(0 . "ARC")
                (mapcar 'cons '(10 50 51 40) lst)
            )
        )
    )
    (princ)
)

;; 3-Point Arc  -  Lee Mac
;; Returns the Center, Start/End Angle and Radius of the
;; Arc defined by three supplied points.

(defun LM:3PArc ( p1 p2 p3 / cn m1 m2 )
    (setq m1 (mid p1 p2)
          m2 (mid p2 p3)
    )
    (if
        (setq cn
            (inters
                m1 (polar m1 (+ (angle p1 p2) (/ pi 2.)) 1.0)
                m2 (polar m2 (+ (angle p2 p3) (/ pi 2.)) 1.0)
                nil
            )
        )
        (append (list cn)
            (if (LM:Clockwise-p p1 p2 p3)
                (list (angle cn p3) (angle cn p1))
                (list (angle cn p1) (angle cn p3))
            )
            (list (distance cn p1))
        )
    )
)

;; Midpoint  -  Lee Mac
;; Returns the midpoint of two points

(defun mid ( a b )
    (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) a b)
)

;; Clockwise-p  -  Lee Mac
;; Returns T if p1,p2,p3 are clockwise oriented

(defun LM:Clockwise-p ( p1 p2 p3 )
    (&amp;lt; (* (- (car  p2) (car  p1)) (- (cadr p3) (cadr p1)))
       (* (- (cadr p2) (cadr p1)) (- (car  p3) (car  p1)))
    )
)
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above uses my 3-Point Arc function from &lt;A href="http://bit.ly/1DDTyED" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lee&lt;/P&gt;</description>
      <pubDate>Sat, 21 Feb 2015 13:04:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/drawing-arcs-with-autolisp/m-p/5515536#M143670</guid>
      <dc:creator>Lee_Mac</dc:creator>
      <dc:date>2015-02-21T13:04:45Z</dc:date>
    </item>
  </channel>
</rss>

