<?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: Edit/Append XDATA in Block Definition? in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9714421#M70990</link>
    <description>&lt;P&gt;Thanks a lot for your anser,&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5680873"&gt;@CodeDing&lt;/a&gt;&amp;nbsp;! I indeed misread an XDATA (1001) section in a block definition as belonging to that block. Instead, ist actually belonged to the INSERT right above it. Attaching my custom stuff to that very INSERT now solved my problem&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards from Vienna,&lt;/P&gt;&lt;P&gt;Heinz&lt;/P&gt;</description>
    <pubDate>Thu, 27 Aug 2020 07:28:53 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-08-27T07:28:53Z</dc:date>
    <item>
      <title>Edit/Append XDATA in Block Definition?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9704088#M70987</link>
      <description>&lt;P&gt;I need to append custom XDATA to a block definition, using plain AutoLISP.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I came up with the following routine, that works fine for general entities, e.g. a circle in the drawing:&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;LI-CODE lang="general"&gt;(defun write-xdata-to-app(entity appname datalist / entityData exdata newent)
	;; register application name
	(regapp appname) 
	;; read entity data
	(setq entityData (entget entity))
	;; set name of app as first entry
 	(setq datalist (cons appname datalist))
	;; sets the variable exdata equal to the new extended data—in this case, a text string.
  (setq exdata
    (list
			(list -3 datalist)
    )
  )
	;; appends new data list to entity's list.
  (setq newent (append entityData exdata)) 
  ;; modify the entity with the new definition data.
	(entmod newent)
)&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;However, getting the entity name for a &lt;STRONG&gt;block definition&lt;/STRONG&gt;&amp;nbsp;with&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;LI-CODE lang="general"&gt;(setq block-def-entity-name (tblsearch&amp;nbsp;"BLOCK"&amp;nbsp;"myBlockName"))&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;, using my routine to append some xdata and displaying all xdata for that entity using&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;LI-CODE lang="general"&gt;(cdr (assoc -3 (entget block-def-entity-name (list "*"))))&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;does not give me anything, even though there's already some xdata in that block definition, which can clearly be seen by reading the DXF's "0 BLOCK" group for that block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 08:29:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9704088#M70987</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-21T08:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Edit/Append XDATA in Block Definition?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9705307#M70988</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can&amp;nbsp;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;not&lt;/STRONG&gt;&lt;/FONT&gt; assign XDATA to a &lt;FONT color="#000000"&gt;&lt;STRONG&gt;Block Definition&lt;/STRONG&gt;&lt;/FONT&gt;. You can assign it to a &lt;FONT color="#000000"&gt;&lt;STRONG&gt;block instance&lt;/STRONG&gt;&lt;/FONT&gt; though..&lt;/P&gt;&lt;P&gt;You can test this with your function like so, and it will return either &lt;U&gt;nil&lt;/U&gt; or an &lt;U&gt;entity list&lt;/U&gt;:&lt;/P&gt;&lt;PRE&gt;(write-xdata-to-app &lt;FONT color="#FF6600"&gt;(tblobjname "BLOCK" "myBlock")&lt;/FONT&gt; "myApp" '((1002 . "{") (1000 . "abcdef") (1002 . "}")))
...OR...
(write-xdata-to-app &lt;FONT color="#FF6600"&gt;(car (entsel "\nSelect Block: "))&lt;/FONT&gt; "myApp" '((1002 . "{") (1000 . "abcdef") (1002 . "}")))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, if I were to assume, you are selecting a &lt;U&gt;block instance&lt;/U&gt; and assigning the XDATA to that, then instead of retrieving that block instance you are mistakenly retrieving the &lt;U&gt;block definition&lt;/U&gt;..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps. if you have any questions please don't hesitate to ask.&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 20:04:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9705307#M70988</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2020-08-21T20:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Edit/Append XDATA in Block Definition?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9708533#M70989</link>
      <description>&lt;P&gt;However, you could ad the xdata to the first entity in the block definition.&lt;/P&gt;
&lt;P&gt;For example, I made a block named "X" of just a bunch of lines.&lt;/P&gt;
&lt;P&gt;Then:&lt;/P&gt;
&lt;P&gt;Command: (setq e2 (tblsearch "block" "x"))&lt;BR /&gt;((0 . "BLOCK") (2 . "x") (70 . 0) (10 0.0 0.0 0.0) (-2 . &amp;lt;Entity name: &lt;BR /&gt;40081de0&amp;gt;))&lt;/P&gt;
&lt;P&gt;Command: (setq e2 (cdr (assoc -2 e2)))&lt;BR /&gt;&amp;lt;Entity name: 40081de0&amp;gt;&lt;/P&gt;
&lt;P&gt;Command: (write-xdata-to-app e2 "JFU" '((1000 . "abc")))&lt;BR /&gt;((-1 . &amp;lt;Entity name: 40081de0&amp;gt;) (0 . "LINE") (330 . &amp;lt;Entity name: 40081dc8&amp;gt;) (5 &lt;BR /&gt;. "3C") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbLine") (10 1.16052 &lt;BR /&gt;-0.716949 0.0) (11 -0.824577 -0.701695 0.0) (210 0.0 0.0 1.0) (-3 ("JFU" (1000 &lt;BR /&gt;. "abc"))))&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 15:28:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9708533#M70989</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2020-08-24T15:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Edit/Append XDATA in Block Definition?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9714421#M70990</link>
      <description>&lt;P&gt;Thanks a lot for your anser,&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5680873"&gt;@CodeDing&lt;/a&gt;&amp;nbsp;! I indeed misread an XDATA (1001) section in a block definition as belonging to that block. Instead, ist actually belonged to the INSERT right above it. Attaching my custom stuff to that very INSERT now solved my problem&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards from Vienna,&lt;/P&gt;&lt;P&gt;Heinz&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 07:28:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9714421#M70990</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-27T07:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Edit/Append XDATA in Block Definition?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9714440#M70991</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt;&amp;nbsp;, thanks for your comment! I actually succeeded in adding XDATA to a block definition itself, by just placing a (-3 ...) in the respective ENTMAKE section of groupcode (0 - BLOCK). The XDATA could also be read from the actual block definition afterwards. However, my problem was that i was of the impression of needing to add XDATA to a block definition that already existed (and was produced elsewhere). Which, obviously, is not possible. It turned out, though, that the XDATA i thought belonged to that block definition, actually belonged to an INSERT within that block definition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Heinz&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 07:38:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/edit-append-xdata-in-block-definition/m-p/9714440#M70991</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-27T07:38:46Z</dc:date>
    </item>
  </channel>
</rss>

