<?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: Command from lisp into tool palette does not work correctly on the first call, but works on the subsequent calls in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11647468#M36459</link>
    <description>&lt;P&gt;It's weird. But it's just the RECTANG. No other command.&amp;nbsp;So I guess... PLINE seems more than a convenient &lt;SPAN&gt;substitution&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW it's so weird that if you use LINE and RECTANG right behind each other, the layer is applied to LINE but not to RECTANG.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Dec 2022 12:40:29 GMT</pubDate>
    <dc:creator>ВeekeeCZ</dc:creator>
    <dc:date>2022-12-30T12:40:29Z</dc:date>
    <item>
      <title>Command from lisp into tool palette does not work correctly on the first call, but works on the subsequent calls</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11646021#M36455</link>
      <description>&lt;P&gt;Hi, I am facing a weird issue with a command from a lisp I created and the tool palette.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My lisp (which I have heavily stripped down for demo/debugging purposes) just creates a rectangle from 2 points. From this lisp I created a tool which I placed in a palette. In the properties of the tool, I set the layer to my liking. The problem is that when I use this tool &lt;U&gt;&lt;STRONG&gt;for the 1st time when I open Autocad&lt;/STRONG&gt;&lt;/U&gt;, the rectangle is &lt;STRONG&gt;not created on the specified layer&lt;/STRONG&gt;, but in whatever the current layer is. &lt;STRONG&gt;But every subsequent time I use the tool&lt;/STRONG&gt;, either is the same drawing or in a new drawing, the rectangle is &lt;STRONG&gt;drawn on the correct layer&lt;/STRONG&gt; (the one that is specified inside the tool properties)! This works correctly until I close autocad. Next time I open it, the same happens. The 1st time the layer is wrong, all subsequent times the layer is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In sort, the steps to reproduce are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Open Autocad.&lt;/P&gt;&lt;P&gt;2. Load the attached lisp file.&lt;/P&gt;&lt;P&gt;3. Create a line or whatever tool in a palette.&lt;/P&gt;&lt;P&gt;4. In the tool properties, set &lt;EM&gt;use flyout&lt;/EM&gt; to &lt;EM&gt;no&lt;/EM&gt; and change the &lt;EM&gt;command string&lt;/EM&gt; to this &lt;EM&gt;^C^C_topogridcross&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;5. In the tool properties, set the &lt;EM&gt;layer&lt;/EM&gt; to any layer you like, except 0 or the current layer of your drawing.&lt;/P&gt;&lt;P&gt;6. Use the tool. --&amp;gt; You should get the rectangle on the wrong layer.&lt;/P&gt;&lt;P&gt;7. Use the tool again. --&amp;gt; You should now get the rectangle on the correct layer!&lt;/P&gt;&lt;P&gt;8. Create a new drawing. Use the tool. --&amp;gt; You should get the rectangle on the correct layer!&lt;/P&gt;&lt;P&gt;9. Close Autocad.&lt;/P&gt;&lt;P&gt;10. Repeat steps 1-8. --&amp;gt; You should see the same results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone explain what's going on? It's driving me crazy. I guess something is not set correctly or initialized when I first use the command from the lisp file, but what is it? And how is it set automatically after the first call?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 01:48:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11646021#M36455</guid>
      <dc:creator>spyros.n7</dc:creator>
      <dc:date>2022-12-29T01:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Command from lisp into tool palette does not work correctly on the first call, but works on the subsequent calls</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11646041#M36456</link>
      <description>&lt;P&gt;Maybe a little rearrange press Enter to exit when asked for point 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(vl-load-com)
(regapp "AcAecLayerStandard") ; For being able to set layer description


(defun C:topogridcross ( / *error* x1 y1 x2 y2 pt1 pt2)

  (defun *error* (msg) ; restore osnap mode in case of error or cancelation
    (if (not (member msg '("Function cancelled" "quit / exit abort")))
      (princ (strcat "\nError: " msg))
    )
    (princ)
  )

    ;pick first point of the grid
  (while (setq pt1 (getpoint "\n Give 1st point: ")
    x1 (car pt1)
    y1 (cadr pt1))
    ;pick second point of the grid
    (setq pt2 (getpoint "\n Give 2nd point: ")
    x2 (car pt2)
    y2 (cadr pt2))
    (command "rectangle" (list x1 y1) (list x2 y2))
  )
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 02:22:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11646041#M36456</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2022-12-29T02:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Command from lisp into tool palette does not work correctly on the first call, but works on the subsequent calls</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11647316#M36457</link>
      <description>&lt;P&gt;Hi, thanks but still doesn't work. Same behavior.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does it work for you? were you able to reproduce the issue I described?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What are we looking for as the cause of the problem? I happen to be a programmer, but this kind of behavior is very strange to me...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 19:13:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11647316#M36457</guid>
      <dc:creator>spyros.n7</dc:creator>
      <dc:date>2022-12-29T19:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Command from lisp into tool palette does not work correctly on the first call, but works on the subsequent calls</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11647352#M36458</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6467263"&gt;@spyros.n7&lt;/a&gt;&amp;nbsp; hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all you are right, it looks like it's a bug in tools palette and&amp;nbsp;the solution i found for this is to modify the command string tools palette:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;^C^Clayer m &lt;FONT color="#0000FF"&gt;ccccc&lt;/FONT&gt; c &lt;FONT color="#0000FF"&gt;N ccccc&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/FONT&gt; topogridcross&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;copy &amp;amp; paste the above macro into command string field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;replace &lt;FONT color="#0000FF"&gt;ccccc&lt;/FONT&gt; with your preferred layer&lt;/P&gt;&lt;P&gt;replace &lt;FONT color="#0000FF"&gt;N&lt;/FONT&gt; with color number (&lt;FONT color="#FF0000"&gt;1 for read&lt;/FONT&gt;, &lt;FONT color="#FFCC00"&gt;2 for yellow&lt;/FONT&gt;, &lt;FONT color="#00FF00"&gt;3 for green&lt;/FONT&gt;....)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if it's hard to modify it on the command string field, modify the command in your notepad than copy &amp;amp; paste it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and if i may advice a more well design for your topogridcross command&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;enjoy&lt;/P&gt;&lt;P&gt;moshe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:topogridcross (/ *error* pt1 pt2)

  (defun *error* (msg) ; restore osnap mode in case of error or cancelation
   (if (not (member msg '("Function cancelled" "quit / exit abort")))
      (princ (strcat "\nError: " msg))
   )
    (princ)
  )

  (while (and
	  (setq pt1 (getpoint "\nPick 1st point: "))
	  (setq pt2 (getcorner pt1 "\nPick second point: "))
        )
    (command "._rectangle" "_none" pt1 "_none" pt2)
  )

 (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 19:34:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11647352#M36458</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2022-12-29T19:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Command from lisp into tool palette does not work correctly on the first call, but works on the subsequent calls</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11647468#M36459</link>
      <description>&lt;P&gt;It's weird. But it's just the RECTANG. No other command.&amp;nbsp;So I guess... PLINE seems more than a convenient &lt;SPAN&gt;substitution&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW it's so weird that if you use LINE and RECTANG right behind each other, the layer is applied to LINE but not to RECTANG.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 12:40:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11647468#M36459</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2022-12-30T12:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Command from lisp into tool palette does not work correctly on the first call, but works on the subsequent calls</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11649831#M36460</link>
      <description>Hi, thanks for the workaround. So, where am I supposed to report this bug? I 've never done this before.&lt;BR /&gt;&lt;BR /&gt;Also, thanks for the optimization of the code, but as I wrote in my first post, this is part of a bigger lisp, that does way more than creating a rectangle. I stripped it down for demo purposes. I 'll find a way to include your suggestion to my code though.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Sat, 31 Dec 2022 12:18:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11649831#M36460</guid>
      <dc:creator>spyros.n7</dc:creator>
      <dc:date>2022-12-31T12:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Command from lisp into tool palette does not work correctly on the first call, but works on the subsequent calls</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11650106#M36461</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6467263"&gt;@spyros.n7&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6467263"&gt;@spyros.n7&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi, thanks for the workaround. So, where am I supposed to report this bug? I 've never done this before.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/flame-forum/how-to-contact-autodesk-support-bug-reports-improvement-request/td-p/8908797" target="_blank" rel="noopener"&gt;&amp;gt;&amp;gt; AutoDesk Bug Report &amp;lt;&amp;lt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 31 Dec 2022 17:28:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/command-from-lisp-into-tool-palette-does-not-work-correctly-on/m-p/11650106#M36461</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2022-12-31T17:28:27Z</dc:date>
    </item>
  </channel>
</rss>

