对不起,我对扩展数据很陌生,Xrecords&dictionaries,我从AfraLisp网站上获得了一些代码,我正试图修改它以满足我的需要。我将在Xrecords中存储多个“Part”字典信息。然后我想将这些字典附加到一个实体(下面只显示一个字典,但将来我将有“PartL1,PartL2,PartL3”,它们都将应用于一个实体). 然后沿着这条路走下去,我将制作一个lisp,它将更改每个的“PartNum”、“QTY”和“Spacing”的值。
问题是我无法将Xrecord字典附加到实体的字典中。在我找到这行代码之前,一切都很好:
- (dictadd ent "PartL1" adict)
我不知道我的格式是正确的还是引用错误。请帮帮我,我已经做了研究,我过不了这关。
- (defun c:applyassem (/ vars varlist)
- ;;retrieve XRecord "PartL1" from dictionary "WSI_DICT"
- ;;which in turn calls both functions below
- (setq vars (get-or-make-Xrecord))
- ;;get dictionary were "PartL1" is stored
- (setq adict (cdr (car (dictsearch (namedobjdict) "WSI_DICT"))))
- ;;get entity to app
- (setq ent (car (entsel)))
- (dictadd ent "PartL1" adict)
-
- (princ)
- )
- (defun get-or-create-Dict (/ adict)
- ;;test if "WSI_DICT" is already present in the main dictionary
- (if (not (setq adict (dictsearch (namedobjdict) "WSI_DICT")))
- ;;if not present then create a new one and set the main dictionary as owner
- (progn
-
- (setq adict (entmakex '((0 . "DICTIONARY")(100 . "AcDbDictionary"))))
- ;;if succesfully created, add it to the main dictionary
- (if adict (setq adict (dictadd (namedobjdict) "WSI_DICT" adict)))
- )
- ;;if present then just return its entity name
- (setq adict (cdr (assoc -1 adict)))
- )
- );defun
- (defun get-or-make-Xrecord(/ adict anXrec)
- (cond
- ;;first get our dictionary. make here in case it doesn't exit
- ((setq adict (get-or-create-Dict))
- (cond
- ;;if "WSI_DICT" is now valid then look for "PartL1" Xrecord
- ((not (setq anXrec (dictsearch adict "PartL1")))
- ;;if "PartL1" was not found then create it
- (setq anXrec (entmakex '((0 . "XRECORD")
- (100 . "AcDbXrecord")
- (7 . "PART#") ;will be part number
- (90 . 1) ;will be default qty of part
- (91 . 16) ;will be spacing in inches
- )
- );entmakex
- );setq anXrec
- ;;if creation succeeded then add it to our dictionary
- (if anXrec (setq anXrec (dictadd adict "PartL1" anXrec)))
- );not
-
- ;;if it's already present then just return its entity name
- (setq anXrec
- (cdr (assoc -1(dictsearch adict "PartL1")))
- );setq anxrex
- );cond
- );setq adict
- );cond
- );defun
|