<?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: Trouble using global variable for macro argument in Autolisp. in AutoCAD Forum</title>
    <link>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7543088#M203014</link>
    <description>&lt;P&gt;Thanks a ton!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the risk of being annoying, I'm having trouble understand how strcat helped here.&amp;nbsp; Was it used to let autocad know that there would be a "string" in the values?&amp;nbsp; The string being (getvar 'userr2)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Nov 2017 15:35:26 GMT</pubDate>
    <dc:creator>sarchwba</dc:creator>
    <dc:date>2017-11-14T15:35:26Z</dc:date>
    <item>
      <title>Trouble using global variable for macro argument in Autolisp.</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7542640#M203012</link>
      <description>&lt;P&gt;So I tried for longer than I care to admit to use a global variable as part of a coordinate in an autolisp command.&amp;nbsp; It looks something like this,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(defun C:test1 ()&lt;BR /&gt;(command "-pan" "0,0,0" ""0,(getvar"userr2"),0"")&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My userr2 variable is set to 300'-0" but it either comes back as nil or 300.0 which I tried to fix with the atoi conversion but that I doesn't seem to help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My end goal is to create two commands that pan up and down a certain distance (hundreds of feet) based on the value of a variable that is saved in the drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Related info: I easily created a macro for this with the action recorder but the trouble is different drawings require different distances and it's not efficient having to change the macro each time I enter a new drawing so I'm trying to base the -pan distance on a global variable that is saved in the drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is much appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 13:42:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7542640#M203012</guid>
      <dc:creator>sarchwba</dc:creator>
      <dc:date>2017-11-14T13:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using global variable for macro argument in Autolisp.</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7542782#M203013</link>
      <description>&lt;P&gt;Try it like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(command "-pan" "0,0" (strcat "0," (rtos (getvar 'userr2))))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;btw (itoa) is for Integer to String conversion, but you need to use Real to String conversion, because you're using the userR (as real)&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 14:24:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7542782#M203013</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2017-11-14T14:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using global variable for macro argument in Autolisp.</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7543088#M203014</link>
      <description>&lt;P&gt;Thanks a ton!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the risk of being annoying, I'm having trouble understand how strcat helped here.&amp;nbsp; Was it used to let autocad know that there would be a "string" in the values?&amp;nbsp; The string being (getvar 'userr2)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 15:35:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7543088#M203014</guid>
      <dc:creator>sarchwba</dc:creator>
      <dc:date>2017-11-14T15:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using global variable for macro argument in Autolisp.</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7543154#M203015</link>
      <description>&lt;P&gt;Well I did try to explain before but (at least) one word you may find missing...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;SPAN&gt;btw (itoa) is for Integer to String conversion, but you need to use &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;the (rtos) function as&lt;/STRONG&gt; &lt;/FONT&gt;Real to String conversion, because you're using the userR (as real)&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;getvar&lt;/EM&gt; 'userr returns a &lt;EM&gt;real&lt;/EM&gt; - 300.0&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;rtos&amp;nbsp;&lt;/EM&gt;makes it a &lt;EM&gt;string&lt;/EM&gt; - "300"&amp;nbsp; &amp;nbsp;(the exact format depends on your type and precision setting set in Drawing unit dialog)&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;strcat&lt;/EM&gt; concatenates "0," and your "300" together... to "0,300" ...simple writing strings behind each other does not make them a one string, not in LISP, you need to use the function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-D03ABBC2-939A-44DB-8C93-FC63B64DE4A2" target="_blank"&gt;RTOS HELP&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-4430B1BF-DBB5-49D1-98F9-711B480976A1" target="_blank"&gt;STRCAT&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 15:58:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7543154#M203015</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2017-11-14T15:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using global variable for macro argument in Autolisp.</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7543535#M203016</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3010634"&gt;@sarchwba&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My end goal is to create two commands that pan up and down a certain distance (hundreds of feet) based on the value of a variable that is saved in the drawing.&lt;/P&gt;
&lt;P&gt;....&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can avoid the whole (rtos)/(strcat)/(etc.) issue entirely, if you like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun C:Pan&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;U&lt;/STRONG&gt;&lt;/FONT&gt; ()&lt;BR /&gt;&amp;nbsp; (command "_.pan" '(0 0) (polar '(0 0) &lt;FONT color="#ff0000"&gt;(/ pi 2)&lt;/FONT&gt; (getvar 'USERR2)))&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun C:Pan&lt;FONT color="#008000"&gt;&lt;STRONG&gt;D&lt;/STRONG&gt;&lt;/FONT&gt; ()&lt;BR /&gt;&amp;nbsp; (command "_.pan" '(0 0) (polar '(0 0) &lt;FONT color="#008000"&gt;(* pi 1.5)&lt;/FONT&gt; (getvar 'USERR2)))&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun C:Pan&lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;R&lt;/STRONG&gt;&lt;/FONT&gt; ()&lt;BR /&gt;&amp;nbsp; (command "_.pan" '(0 0) (polar '(0 0)&amp;nbsp;&lt;FONT color="#0000ff"&gt;0&lt;/FONT&gt; (getvar 'USERR2)))&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun C:Pan&lt;FONT color="#ff00ff"&gt;&lt;STRONG&gt;L&lt;/STRONG&gt;&lt;/FONT&gt; ()&lt;BR /&gt;&amp;nbsp; (command "_.pan" '(0 0) (polar '(0 0)&amp;nbsp;&lt;FONT color="#ff00ff"&gt;pi&lt;/FONT&gt; (getvar 'USERR2)))&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[Note that you don't need the Z coordinates.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun C:PanU ()&lt;BR /&gt;&amp;nbsp; (command "_.zoom" "_c" (polar (getvar 'viewctr) (* pi 1.5) (getvar 'USERR2)) "")&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;... etc. ....&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 17:30:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7543535#M203016</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2017-11-14T17:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using global variable for macro argument in Autolisp.</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7543547#M203017</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;for the info!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 17:21:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/trouble-using-global-variable-for-macro-argument-in-autolisp/m-p/7543547#M203017</guid>
      <dc:creator>sarchwba</dc:creator>
      <dc:date>2017-11-14T17:21:30Z</dc:date>
    </item>
  </channel>
</rss>

