helmut51 发表于 2022-7-6 07:53:29

另一种可能性是保存数据。Vladimir Nesterovsky的lsp->http://vnestr.tripod.com/SaveData.lsp

Costinbos77 发表于 2022-7-6 07:59:35

非常好的材料。稍微修改一下,但这就是问题所在。
 
非常感谢您的推荐。

BIGAL 发表于 2022-7-6 08:00:31

另一个例子可能有用
 
(defun get-or-create-Dict (/ adict)

;;test if "MyDict" is already present in the main dictionary
(if (not (setq adict (dictsearch (namedobjdict) "MyDict")))

   ;;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) "MyDict" adict)))
   )

   ;;if present then just return its entity name
   (setq adict (cdr (assoc -1 adict)))
)
)

(defun get-or-make-Xrecord (/ adict anXrec)
; change to allow w1 etc and thickness

(cond
    ;;first get our dictionary. Notice that "MyDict" will be
   ;;created here in case it doesn't exist
   ((setq adict (get-or-create-Dict))
   (cond
       ;;if "MyDict" is now valid then look for "MyDictVARS" Xrecord
      ((not (setq anXrec (dictsearch adict wallvar)))
;the variable MyDictvars is name of xrecord so need to be a variable to add lots
       ;;if "MyDictVARS" was not found then create it
       ;(setq anXrec (entmakex '((0 . "XRECORD")
(setq anXrec (entmakex (list (cons 0"XRECORD")
                               (cons 100"AcDbXrecord")
                               ;(1 . wallvar)
   (cons 1 wallvar)
   (cons 40 wallsize)
    ;(40 . wallsize)
                               )
                  )
       )
       ;;if creation succeeded then add it to our dictionary
       (if anXrec (setq anXrec (dictadd adict wallvar anXrec)))
      )
      ;;if it's already present then just return its entity name
      (setq anXrec
       (cdr (assoc -1 (dictsearch adict wallvar)))
      )
    )
   )
)
)
(defun getMyDictvars (/ vars varlist)
;;retrieve XRecord "wallvar" from dictionary "MyDict"
;;which in turn calls both functions above
(setq vars (get-or-make-Xrecord))

;;if our Xrecord is found, then get values in group code
(cond (vars
      (setq varlist(entget vars))
      (setq WALLname (cdr (assoc 1 varlist)))
      (setq WALLTHICK(cdr (assoc 40 varlist)))
       )

       ;;otherwise return nil
       (T nil)
)
)

irneb 发表于 2022-7-6 08:04:44

取决于你想保存什么。在DWG中保存数据的基本方法有5种:
[列表=1]
[*]图形属性:http://www.cadtutor.net/forum/showthread.php?32034-图形特性
[*]扩展数据
字典内的[*]XRecods
[*]Lisp数据:http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-680c.htm(实际上还使用了一本字典……刚刚为您整理好。我将其包括在内,因为它的使用方式与普通字典有点不同)
[*]图纸集(尽管不严格位于DWg内部):http://www.cadtutor.net/forum/showthread.php?64749-从块填充-Sheet-Set-Custom-Properties-by-gathering-attributes-from-a-block
每种方法都有其用途,您必须决定哪种方法更适合您的情况。E、 g.1表示整个DWG,可以在Windows资源管理器中作为列列出。5是每个选项卡,可以在图纸集管理器中编辑。
 
至于2和3。。。它们可以附着到DWG中的任何内容。。。两者都有优点和缺点,例如:
 
扩展数据具有最大大小,只能处理某些数据类型,而字典没有大小限制,可以有效地处理任何数据。
 
另一方面,扩展数据有一些“智能”类型,如链接句柄和值,这些值随着对父实体的修改一起转换(例如,代码1041将是与实体一起缩放的实值数)http://docs.autodesk.com/ACD/2011/ENU/filesALG/WS73099cc142f4875516d84be10ebc87a53f-7a06.htm)

Costinbos77 发表于 2022-7-6 08:09:39

谢谢你的回答。
 
该变量xx=表示最后绘制编号地块的编号(47)。当我想填充图形时,在字典中查找xx的值并保留它,结果是48、49,依此类推。

BIGAL 发表于 2022-7-6 08:12:48

检查李mac的自动重新编号如果你删除27它将重新编号所有块对象也添加。

irneb 发表于 2022-7-6 08:15:37

是的,对于您所指的内容,我不确定是否有必要存储数据(即使如此,为什么不简单地使用一个UserI变量呢?)您只需找到最后一个数字本身(文字/属性),如果地块使用属性块进行编号,则使用选择集很容易做到这一点。
 
这基本上就是李的AutoLabelAttributes所做的。。。只需检查新的块插入、复制和擦除,然后在不需要额外用户输入的情况下重新编号。
 
或者,我的自动增量例程允许将这些想法放到任何文本/属性库中,并允许从中间的某个位置插入/删除/移动一个。它还展示了如何使用LispData(vlax ldata-*字典)将各个项目相互链接,如果您确实想使用自己的数据存储,IMO将是最简单的方法。

Costinbos77 发表于 2022-7-6 08:18:39

谢谢你的回复。
使用字典很好,因为如果有人删除了包含值xx的属性,那么眼睛就盯着太阳看。
 
users,userr将其用于其他变量。
页: 1 [2]
查看完整版本: 可以在dwg中存储数据吗?