<?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 LISP to update attribute field with current date in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-update-attribute-field-with-current-date/m-p/11554747#M38091</link>
    <description>&lt;P&gt;I am still very new to LISP but I am attempting to deliver a program that will:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Prompt the user to select either one (not not both) of the attribute blocks in the attached drawing file.&lt;/LI&gt;&lt;LI&gt;Prompt the user to choose to update the DESNDATE field, the DRAWDATE field, or &lt;U&gt;both&lt;/U&gt;.&lt;/LI&gt;&lt;LI&gt;Update the chosen fields with the current date in MM/DD/YY&amp;nbsp; format.&amp;nbsp; &amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Quite literally, the only portion I have had success with is using the &lt;EM&gt;print&lt;/EM&gt; function to prompt the user, and &lt;EM&gt;ssget&lt;/EM&gt; for selecting the block.&amp;nbsp; But I am going in circles trying to figure out the rest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the Attribute Functions on&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/569456"&gt;@Lee_Mac&lt;/a&gt;&amp;nbsp;'s&amp;nbsp;website, which from what I have seen are quite popular for this purpose, but after endless trial and error, I remained confused as to exactly which parts of the code I need to replace/update to fit my particular needs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;;; Set Attribute Values  -  Lee Mac&lt;/SPAN&gt;
&lt;SPAN class=""&gt;;; Sets attributes with tags found in the association list to their associated values.&lt;/SPAN&gt;
&lt;SPAN class=""&gt;;; blk - [ent] Block (Insert) Entity Name&lt;/SPAN&gt;
&lt;SPAN class=""&gt;;; lst - [lst] Association list of ((&amp;lt;tag&amp;gt; . &amp;lt;value&amp;gt;) ... )&lt;/SPAN&gt;
&lt;SPAN class=""&gt;;; Returns: nil&lt;/SPAN&gt;

&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;defun&lt;/SPAN&gt; LM:setattributevalues &lt;SPAN class=""&gt;(&lt;/SPAN&gt; blk lst &lt;SPAN class=""&gt;/&lt;/SPAN&gt; enx itm &lt;SPAN class=""&gt;)&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;and&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;setq&lt;/SPAN&gt; blk &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;entnext&lt;/SPAN&gt; blk&lt;SPAN class=""&gt;))&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;"ATTRIB"&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;cdr&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;assoc&lt;/SPAN&gt; &lt;SPAN class=""&gt;0&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;setq&lt;/SPAN&gt; enx &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;entget&lt;/SPAN&gt; blk&lt;SPAN class=""&gt;))))))&lt;/SPAN&gt;
        &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;setq&lt;/SPAN&gt; itm &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;assoc&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;cdr&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;assoc&lt;/SPAN&gt; &lt;SPAN class=""&gt;2&lt;/SPAN&gt; enx&lt;SPAN class=""&gt;))&lt;/SPAN&gt; lst&lt;SPAN class=""&gt;))&lt;/SPAN&gt;
            &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;progn&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;entmod&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;subst&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;cons&lt;/SPAN&gt; &lt;SPAN class=""&gt;1&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;cdr&lt;/SPAN&gt; itm&lt;SPAN class=""&gt;))&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;assoc&lt;/SPAN&gt; &lt;SPAN class=""&gt;1&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;reverse&lt;/SPAN&gt; enx&lt;SPAN class=""&gt;))&lt;/SPAN&gt; enx&lt;SPAN class=""&gt;))&lt;/SPAN&gt;
                    &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;entupd&lt;/SPAN&gt; blk&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;)&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;(&lt;/SPAN&gt;LM:setattributevalues blk lst&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
            &lt;SPAN class=""&gt;)&lt;/SPAN&gt;
            &lt;SPAN class=""&gt;(&lt;/SPAN&gt;LM:setattributevalues blk lst&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
        &lt;SPAN class=""&gt;)&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;)&lt;/SPAN&gt;
&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know it's a huge ask and frankly I wouldn't blame you if you'd rather I tough this out pouring over references for the learning experience, but I have users who would really appreciate having this functionality right now.&lt;/P&gt;&lt;P&gt;Kindest Regards and Deepest Gratitude,&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2022 21:26:32 GMT</pubDate>
    <dc:creator>pete592</dc:creator>
    <dc:date>2022-11-15T21:26:32Z</dc:date>
    <item>
      <title>LISP to update attribute field with current date</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-update-attribute-field-with-current-date/m-p/11554747#M38091</link>
      <description>&lt;P&gt;I am still very new to LISP but I am attempting to deliver a program that will:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Prompt the user to select either one (not not both) of the attribute blocks in the attached drawing file.&lt;/LI&gt;&lt;LI&gt;Prompt the user to choose to update the DESNDATE field, the DRAWDATE field, or &lt;U&gt;both&lt;/U&gt;.&lt;/LI&gt;&lt;LI&gt;Update the chosen fields with the current date in MM/DD/YY&amp;nbsp; format.&amp;nbsp; &amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Quite literally, the only portion I have had success with is using the &lt;EM&gt;print&lt;/EM&gt; function to prompt the user, and &lt;EM&gt;ssget&lt;/EM&gt; for selecting the block.&amp;nbsp; But I am going in circles trying to figure out the rest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the Attribute Functions on&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/569456"&gt;@Lee_Mac&lt;/a&gt;&amp;nbsp;'s&amp;nbsp;website, which from what I have seen are quite popular for this purpose, but after endless trial and error, I remained confused as to exactly which parts of the code I need to replace/update to fit my particular needs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;;; Set Attribute Values  -  Lee Mac&lt;/SPAN&gt;
&lt;SPAN class=""&gt;;; Sets attributes with tags found in the association list to their associated values.&lt;/SPAN&gt;
&lt;SPAN class=""&gt;;; blk - [ent] Block (Insert) Entity Name&lt;/SPAN&gt;
&lt;SPAN class=""&gt;;; lst - [lst] Association list of ((&amp;lt;tag&amp;gt; . &amp;lt;value&amp;gt;) ... )&lt;/SPAN&gt;
&lt;SPAN class=""&gt;;; Returns: nil&lt;/SPAN&gt;

&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;defun&lt;/SPAN&gt; LM:setattributevalues &lt;SPAN class=""&gt;(&lt;/SPAN&gt; blk lst &lt;SPAN class=""&gt;/&lt;/SPAN&gt; enx itm &lt;SPAN class=""&gt;)&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;and&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;setq&lt;/SPAN&gt; blk &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;entnext&lt;/SPAN&gt; blk&lt;SPAN class=""&gt;))&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;"ATTRIB"&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;cdr&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;assoc&lt;/SPAN&gt; &lt;SPAN class=""&gt;0&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;setq&lt;/SPAN&gt; enx &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;entget&lt;/SPAN&gt; blk&lt;SPAN class=""&gt;))))))&lt;/SPAN&gt;
        &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;setq&lt;/SPAN&gt; itm &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;assoc&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;cdr&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;assoc&lt;/SPAN&gt; &lt;SPAN class=""&gt;2&lt;/SPAN&gt; enx&lt;SPAN class=""&gt;))&lt;/SPAN&gt; lst&lt;SPAN class=""&gt;))&lt;/SPAN&gt;
            &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;progn&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;entmod&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;subst&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;cons&lt;/SPAN&gt; &lt;SPAN class=""&gt;1&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;cdr&lt;/SPAN&gt; itm&lt;SPAN class=""&gt;))&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;assoc&lt;/SPAN&gt; &lt;SPAN class=""&gt;1&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;reverse&lt;/SPAN&gt; enx&lt;SPAN class=""&gt;))&lt;/SPAN&gt; enx&lt;SPAN class=""&gt;))&lt;/SPAN&gt;
                    &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;entupd&lt;/SPAN&gt; blk&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;)&lt;/SPAN&gt;
                &lt;SPAN class=""&gt;(&lt;/SPAN&gt;LM:setattributevalues blk lst&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
            &lt;SPAN class=""&gt;)&lt;/SPAN&gt;
            &lt;SPAN class=""&gt;(&lt;/SPAN&gt;LM:setattributevalues blk lst&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
        &lt;SPAN class=""&gt;)&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;)&lt;/SPAN&gt;
&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know it's a huge ask and frankly I wouldn't blame you if you'd rather I tough this out pouring over references for the learning experience, but I have users who would really appreciate having this functionality right now.&lt;/P&gt;&lt;P&gt;Kindest Regards and Deepest Gratitude,&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 21:26:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-update-attribute-field-with-current-date/m-p/11554747#M38091</guid>
      <dc:creator>pete592</dc:creator>
      <dc:date>2022-11-15T21:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to update attribute field with current date</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-update-attribute-field-with-current-date/m-p/11554757#M38092</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/37301"&gt;@pete592&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Give this a try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;(defun c:foo (/ d s)
  (setq d (menucmd "M=$(edtime, $(getvar,date),MO/DD/YY)"))
  (if (setq s (ssget ":L" '((0 . "INSERT") (66 . 1))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (foreach tag '("DESNDATE" "DRAWDATE") (vl-catch-all-apply 'setpropertyvalue (list e tag d)))
    )
  )
  (princ)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 21:35:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-update-attribute-field-with-current-date/m-p/11554757#M38092</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2022-11-15T21:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to update attribute field with current date</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-update-attribute-field-with-current-date/m-p/11554909#M38093</link>
      <description>&lt;P&gt;Thank you so much!&amp;nbsp; I'm going to dive into what you did and learn from this!&lt;/P&gt;&lt;P&gt;I had a feeling this could be done with only a few lines of code and you did not disappoint!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My coworkers and I thank you again.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 22:59:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-update-attribute-field-with-current-date/m-p/11554909#M38093</guid>
      <dc:creator>pete592</dc:creator>
      <dc:date>2022-11-15T22:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to update attribute field with current date</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-update-attribute-field-with-current-date/m-p/11555208#M38094</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/37301"&gt;@pete592&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much!&amp;nbsp; I'm going to dive into what you did and learn from this!&lt;/P&gt;
&lt;P&gt;I had a feeling this could be done with only a few lines of code and you did not disappoint!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My coworkers and I thank you again.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/37301"&gt;@pete592&lt;/a&gt;&amp;nbsp; Glad to help. *cheers*&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 02:20:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-update-attribute-field-with-current-date/m-p/11555208#M38094</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2022-11-16T02:20:18Z</dc:date>
    </item>
  </channel>
</rss>

