检查是否存在对象或形状
在示例中,我有一个名为“picket”的对象,我想检查是否有这些picket,然后需要将它们放入一个具有实体名称的列表中。如何使用vlax ldata put执行此操作。把这些数据放入数据库?所有工作函数都是这样的。。我在命令输入中键入命令(所有_数据),并在autocad内存中键入所需的数据保存,然后在控制台中,我可以使用命令vlax ldata list进行检查
(defun c:tinklolinija (/ test pradzios_taskas)
(vl-load-com)
(while
(if (tblsearch "block" "Piketas")
(princ "\nBlock Piketas not found.")
)
)
(princ)
)
有人帮忙吗?如何获取实体名称? 查看如何使用SSGET和过滤器,您可以搜索名为picket的块。
(setq ss (ssget "X" (list (cons 0 "Insert")(cons 2 "Picket")))) 我编写了在alertbox中打印计数对象名称的代码,但它不显示实体名称。。我错过了什么?
(defun c:bcount ( / p1 b a n obj name)
(setq p1 (getstring "\Name of Block : "))
;get the name of the block
(setq b (cons 2 p1))
;construct a dotted pair - code 2 is for blocks
(setq a (ssget "x" (list b)))
;filter for the block name
(progn
)
(if (/= a nil)
;check if there are any blocks of that name
(progn
;if there is…
(setq n (sslength a))
(setq ent (entlast a))
;count the number of blocks
(alert (strcat "\nThere are " (itoa n)" in the DataBase. Enity: " (itoa ent) ))
;display the result
);progn
;if there are no blocks
(alert "\nThere are none in the DataBase")
;inform the user
);if
(princ)
) 实体名称需要显示什么? 在这种情况下,块的名称并不是我所需要的全部,但现在它很复杂。。嗯,我需要另一种方法来获取块名实体。有并没有办法使用vlax ldata put将ta实体名放入数据库来检查块的确切名称是否存在? 看我的帖子,用p1替换“纠察队”
此外,“\名称应为”\n名称表示新行。 我注意到了现有名称与显示选择集和一些数字的不同,p1返回零 此示例将显示选定对象的实体名称和vla对象名称:
(vl-load-com)
(setq entity
(car
(entsel "\nSelect Item: ") ; select item
)
)
(if entity ; check if something selected
(progn ; if so, do some stuff
(princ (strcat "\nEntity is a: " ; combine some strings
(vl-princ-to-string (type entity))
; convert type-output to string
)
)
(princ (strcat "\nThe entity name is: "
(vl-princ-to-string entity)
)
)
)
)
(princ "\nAnd now VLA-data:")
(setq a-vla-object
(vlax-ename->vla-object entity) ; convert a ename to a vla-object
)
(princ
(strcat "\nVLA-Entity: " (vl-princ-to-string a-vla-object))
) 没关系,我看到它得到了实体名,但对我来说,仍然需要这些实体名计数并写入数据库。没有使用entsel函数,我的意思是自动。。当您按comman line中的function时
页:
[1]
2