Message 1 of 5
Not applicable
08-21-2020
01:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to append custom XDATA to a block definition, using plain AutoLISP.
I came up with the following routine, that works fine for general entities, e.g. a circle in the drawing:
(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)
)
However, getting the entity name for a block definition with
(setq block-def-entity-name (tblsearch "BLOCK" "myBlockName"))
, using my routine to append some xdata and displaying all xdata for that entity using
(cdr (assoc -3 (entget block-def-entity-name (list "*"))))
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.
Solved! Go to Solution.