gpt4 book ai didi

lisp - 一个实体中的对象 react 器 "copied"和 "modified"出错了 - 需要帮助

转载 作者:太空宇宙 更新时间:2023-11-03 19:01:28 24 4
gpt4 key购买 nike

我的意图是创建一些包含两个文本的行,每个文本都有简短的信息(作为一个组制作),并让 react 器分配给该行确保:

  1. 复制时,每个实体的句柄将更新为其他实体的信息,并且
  2. 如果我使用末端夹点拉伸(stretch)线条,线条 react 器会将线条的长度更新为存储的扩展数据,并更新与长度对应的文本值。

到目前为止,在这个论坛的宝贵帮助下,我能够复制故事的一部分。当我尝试将“已修改”选项合并到 react 器中时,它不起作用。下面是我使用的代码。

第一个函数在创建过程中通过另一个函数将 react 器分配给线路,此处未显示。剩下的就是回调等等。任何建议表示赞赏。

继续这个问题:

How to update xdata information of an entity when it is copied

(defun assign_LLreactor (LL_ename LL_Length LL_Size / LL_ename LL_hLength LL_hSize)
(if (= 'vlr-object-reactor (type lineReactor))
(vlr-owner-add lineReactor (vlax-ename->vla-object LL_ename))
(vlr-set-notification
(setq lineReactor
(vlr-object-reactor (list (vlax-ename->vla-object LL_ename)) "Line Reactor"
'(
(:vlr-modified . LL_callback_mod)
(:vlr-copied . LL_callback)
)
)
)
'active-document-only
)
)

(makeagroup (ssadd (handent LL_Length) (ssadd (handent LL_Size) (ssadd LL_ename (ssadd)))))
)

(defun LL_callback (notifierobj reactorobj paramls)
(if (/= 0 (car paramls))
(progn
(setq LL_owner (append LL_owner (list (car paramls))))
(vlr-command-reactor "LL_copied_re"
'(
(:vlr-commandended . LL_copyended)
(:vlr-commandcancelled . LL_copycancelled)
(:vlr-commandfailed . LL_copycancelled)
)
)
)
)
)

(defun LL_callback_mod (owner reactorobj paramls)
(setq LL_owner (append LL_owner (list owner)))
(vlr-command-reactor "LL_modified_re"
'(
(:vlr-commandended . LL_modifiedended)
(:vlr-commandcancelled . LL_modifiedcancelled)
(:vlr-commandfailed . LL_modifiedcancelled)
)
)
)

(defun LL_copyended ( reactor params / enametxt txt1 txt2 hSize hLength groupedentities txthandles grtxtdata)
(vlr-remove reactor)

(if
(and
(setq LL_ent (car LL_owner))
(setq LL_enx (entget LL_ent '("LL_U")))
(= (cdr (assoc 0 LL_enx)) "LINE")
(setq LL_3data (assoc -3 LL_enx))
)
(progn
(foreach n (setq groupedentities (_groupedenames LL_ent))
(if (= (cdr (assoc 0 (setq grtxtdata (entget n '("LL_U"))))) "TEXT")
(progn
(setq txthandles (append txthandles (list (cdr (assoc 5 grtxtdata)))))
(entmod (subst (list -3 (list "LL_U" (cons 1005 (cdr (assoc 5 LL_enx))))) (assoc -3 grtxtdata) grtxtdata))
)
)
)
(setq txthandles (vl-sort txthandles (function (lambda (a b) (< a b)))))
(entmod (subst (list -3 (list "LL_U" (cons 1005 (cadr txthandles)) (cons 1005 (car txthandles)))) (assoc -3 LL_enx) LL_enx))
)
)

(if (and LL_enx (= 'vlr-object-reactor (type lineReactor)))
(vlr-owner-add lineReactor (vlax-ename->vla-object LL_ent))
)

(setq LL_owner (cdr LL_owner))
(princ)
)

(defun LL_modifiedended ( reactor params / LL_ent LL_enx llpt10 llpt11 LL_3data LL_3data_n)
(if
(and
(setq LL_ent (car LL_owner))
(setq LL_enx (entget LL_ent '("Pdata")))
(= (cdr (assoc 0 LL_enx)) "LINE")
(setq LL_3data (assoc -3 LL_enx))
)
(progn
(if (= 'vlr-object-reactor (type lineReactor))
(vlr-remove lineReactor)
)
(setq llpt10 (cdr (assoc 10 LL_enx)))
(setq llpt11 (cdr (assoc 11 LL_enx)))
(setq LL_3data_n (list -3 (subst (cons 1000 (rtos (distance llpt10 llpt11) 2 3)) (nth 2 (cadr LL_3data)) (cadr LL_3data))))
(ht_ss (ssadd (cdr (assoc -1 (entmod (subst LL_3data_n (assoc -3 LL_enx) LL_enx)))) (ssadd)))

(if (= 'vlr-object-reactor (type lineReactor))
(vlr-add lineReactor)
)
)
)
(princ)
)

(defun LL_copycancelled ( reactor params )
(vlr-remove reactor)
(setq LL_owner nil)
(princ)
)

(defun LL_modifiedcancelled ( reactor params )
(vlr-remove reactor)
(setq LL_owner nil)
(princ)
)

我希望对象 react 器适用于“修改”和“复制”操作,用于拉伸(stretch)或复制更新的 xdata 和文本的行。

最佳答案

因此,我设法通过为特定 react 器类型(例如“复制”或“修改”)的所有者使用单独的列表来解决问题。所以“LL_owner”列表变成了两个,“LL_copy_owner”和“LL_mod_owner”。现在它工作正常(直到另行通知:)。

关于lisp - 一个实体中的对象 react 器 "copied"和 "modified"出错了 - 需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57170631/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com