<?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 Better way to define constant symbol? in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9283610#M79134</link>
    <description>&lt;P&gt;I looking for a better way to define a constant symbol, so that it evaluates when used.&lt;/P&gt;&lt;P&gt;Currently:&lt;/P&gt;&lt;PRE&gt;(setq rot pi)&lt;BR /&gt;....
  (setq BKROT (quote (and (&amp;gt; rot (* pi 0.5)) (&amp;lt;= rot (* pi 1.5))))) ; define constant for Back Rotation
....
 (cond
	       ((eval BKROT) (something happens))
.....
(cond
	       ((not (eval BKROT)) (something happens))
......&lt;BR /&gt;&lt;BR /&gt;;; what I would like&lt;BR /&gt;&lt;BR /&gt;(setmagic BKROT (quote (and (&amp;gt; rot (* pi 0.5)) (&amp;lt;= rot (* pi 1.5))))) ; define self evaluating constant&lt;BR /&gt;.....&lt;BR /&gt;&amp;nbsp;(cond ( BKROT (something happens)) .....&lt;/PRE&gt;</description>
    <pubDate>Wed, 29 Jan 2020 19:01:46 GMT</pubDate>
    <dc:creator>mmitchellH6TRW</dc:creator>
    <dc:date>2020-01-29T19:01:46Z</dc:date>
    <item>
      <title>Better way to define constant symbol?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9283610#M79134</link>
      <description>&lt;P&gt;I looking for a better way to define a constant symbol, so that it evaluates when used.&lt;/P&gt;&lt;P&gt;Currently:&lt;/P&gt;&lt;PRE&gt;(setq rot pi)&lt;BR /&gt;....
  (setq BKROT (quote (and (&amp;gt; rot (* pi 0.5)) (&amp;lt;= rot (* pi 1.5))))) ; define constant for Back Rotation
....
 (cond
	       ((eval BKROT) (something happens))
.....
(cond
	       ((not (eval BKROT)) (something happens))
......&lt;BR /&gt;&lt;BR /&gt;;; what I would like&lt;BR /&gt;&lt;BR /&gt;(setmagic BKROT (quote (and (&amp;gt; rot (* pi 0.5)) (&amp;lt;= rot (* pi 1.5))))) ; define self evaluating constant&lt;BR /&gt;.....&lt;BR /&gt;&amp;nbsp;(cond ( BKROT (something happens)) .....&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Jan 2020 19:01:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9283610#M79134</guid>
      <dc:creator>mmitchellH6TRW</dc:creator>
      <dc:date>2020-01-29T19:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Better way to define constant symbol?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9283686#M79135</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5422624"&gt;@mmitchellH6TRW&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then just perform the evaluation..?&lt;/P&gt;&lt;PRE&gt;(setq BKROT (and (&amp;gt; rot (* pi 0.5)) (&amp;lt;= rot (* pi 1.5))))
.....
(cond (BKROT (something happens)) .....&lt;/PRE&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2020 19:27:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9283686#M79135</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2020-01-29T19:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: Better way to define constant symbol?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9283997#M79136</link>
      <description>&lt;P&gt;Are you talking about defining a function to pass a rotation argument to?&lt;/P&gt;&lt;PRE&gt;(defun _mycheck (rot) (&amp;lt;= (/ pi 2) rot (* pi 1.5)))
(if (_mycheck (getangle)) (alert "YES :)")(alert "NO :("))&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Jan 2020 21:55:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9283997#M79136</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2020-01-29T21:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Better way to define constant symbol?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9284267#M79137</link>
      <description>&lt;P&gt;I'm trying to picture what the (quote) function is doing for you.&amp;nbsp; The (and) function that it is applied to will return either T [with the value of pi at the beginning] or nil, so BKROT is going to be set to either (quote T) or (quote nil).&amp;nbsp; I'm not at an AutoCAD to try, but I'm wondering what those do -- whether they even have any meaning....&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 00:30:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9284267#M79137</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2020-01-30T00:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Better way to define constant symbol?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9285404#M79138</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5422624"&gt;@mmitchellH6TRW&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I know what you're going for, and this is as close as I can get. You have to call it as a function though [with brackets (...) ]. I'm not sure how to run the expression if you were to just call the symbol without brackets.&lt;/P&gt;&lt;P&gt;Is this more-so what you're looking for?&lt;/P&gt;&lt;PRE&gt;.....
(setq rot pi)
(setq BKROT (lambda () (and (&amp;gt; rot (* pi 0.5)) (&amp;lt;= rot (* pi 1.5))))) ; define constant for Back Rotation
(cond ((BKROT) (something happens)) .....
(setq rot 0.0)
(cond ((not (BKROT)) (something ELSE happens)) .....
.....&lt;/PRE&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 13:27:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9285404#M79138</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2020-01-30T13:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Better way to define constant symbol?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9286284#M79139</link>
      <description>&lt;PRE&gt;  (setq TAU (* pi 2))
  (setq BKROT (lambda () (and (&amp;gt; rot (* TAU 0.25)) (&amp;lt;= rot (* TAU 0.75))))) ; define constant for Back Rotation&lt;/PRE&gt;&lt;P&gt;is a condition to test of rot is on the back side of a circle.&amp;nbsp; So later in the code I can call the condition....&lt;/P&gt;&lt;PRE&gt;	     (cond
	       ((BKROT) (cons 50 (+ rot pi (cdr (assoc 50 x))))) ; insertion angle on back side
	       (T (cons 50 (+ rot (cdr (assoc 50 x)))))	    ; insertion angle on front side
	     )						    ; (cond&lt;/PRE&gt;&lt;P&gt;as part of my entmake . The (assoc 50 x) pulls the insert angle from the original block. i.e.&amp;nbsp;&amp;nbsp;&lt;A title="Trying to entmake a block insert with attributes..." href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-entmake-a-block-insert-with-attributes/m-p/9280184/highlight/true#" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-entmake-a-block-insert-with-attributes/m-p/9280184/highlight/true#&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;	     (cond
	       ((BKROT) (cons 72 2))		    	    ; Horz 0 = Left; 1= Center; 2 = Right
	       (T (cons 72 0))				    ; Horz 0 = Left; 1= Center; 2 = Right
	     )						    ; (cond&lt;/PRE&gt;&lt;P&gt;Eight different calls to place blocks.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Array.png" style="width: 189px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/723899iCE7D52C4BFDA04E1/image-size/small?v=v2&amp;amp;px=200" role="button" title="Array.png" alt="Array.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 18:26:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9286284#M79139</guid>
      <dc:creator>mmitchellH6TRW</dc:creator>
      <dc:date>2020-01-30T18:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Better way to define constant symbol?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9286449#M79140</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5422624"&gt;@mmitchellH6TRW&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not to interrupt your flow or anything, but perhaps some simple 'improvements'?&lt;/P&gt;&lt;PRE&gt;(cond
  ((BKROT) (cons 50 (+ rot pi (cdr (assoc 50 x))))) ; insertion angle on back side
  (T (cons 50 (+ rot (cdr (assoc 50 x)))))	    ; insertion angle on front side
)
&lt;FONT color="#3366FF"&gt;...to...&lt;/FONT&gt;
(cons 50 (+ rot (if (BKROT) pi 0.0) (cdr (assoc 50 x))))&lt;/PRE&gt;&lt;PRE&gt;(cond
  ((BKROT) (cons 72 2))	; Horz 0 = Left; 1= Center; 2 = Right
  (T (cons 72 0))	; Horz 0 = Left; 1= Center; 2 = Right
)
&lt;FONT color="#3366FF"&gt;...to...&lt;/FONT&gt;
(cons 72 (if (BKROT) 2 0))&lt;/PRE&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 19:23:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9286449#M79140</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2020-01-30T19:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Better way to define constant symbol?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9286504#M79141</link>
      <description>&lt;P&gt;Thank you DD.&lt;/P&gt;&lt;P&gt;I see how you did that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 19:44:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/better-way-to-define-constant-symbol/m-p/9286504#M79141</guid>
      <dc:creator>mmitchellH6TRW</dc:creator>
      <dc:date>2020-01-30T19:44:13Z</dc:date>
    </item>
  </channel>
</rss>

