哇,当你的两个想法结合在一起时,这个工具工作得更好。恐怕成功只会让任务大师变得贪婪。现在按钮可以工作了,我正在努力防止人为错误。(翻译——全部重写)
情况:如果动态块最初放置在正确的层上,则正确选择了它们。但是,当用户在错误的层上放置块时,很少出现1。然后,该按钮不会选择块,因为它已硬连接到层名称。因此,我试图通过有效块名进行选择,使选择集工作。我浏览过网络,知道我必须使用vba“有效名称”工具,但我想不出将其放在lisp中的最佳位置,或者如何将例程连接在一起。
是的,所有这些都可以通过quickselect通过几次单击来完成,但这些选择集每天要完成数百次,因此只需单击一次即可。接下来,任务主管希望我构建更多在其中使用相同工具的Lisp,并在此基础上进行构建。(小规模的成功让他觉得我可以做大事。我一直告诉他我对自己在做什么知之甚少,但这似乎并没有阻止他的要求。)(是的,他看了这个论坛。哈哈)
以下是我需要在lisp中实现的4个步骤:
1.选择所有名为“elect\u transformr\u bank\u point”或“*u*”的块。使用MSau中的“selectblock”。它真的很好用。
2.获取selectblock lisp选择的所有*u*块的有效名称。使用pBe中的EFname lisp,它可以一次在一个块上很好地工作。
3.从选择集中筛选出与“elect\u transformr\u bank\u point”不匹配的任何有效名称。
4.用块名称或有效名称“elect\u transformr\u bank\u point”创建剩余块的活动选择集。使用MSau的“selectblock”lisp的最后几行
以下是我尝试过的:
从pBe开始:
- defun c:test (/ ss en) ;;Written by pBe in this [url="http://www.cadtutor.net/forum/showthread.php?64785-How-to-get-the-original-block-name-of-a-dynamic-block&highlight=EFFECTIVE+BLOCK"]thread[/url].
- (defun _EFName (ent)
- (vl-load-com)
- (vla-get-effectivename (vlax-ename->vla-object ent)))
- (if (setq ss (ssget '((0 . "INSERT")(2 . "ELECT_TRANSFORMR_BANK_POINT,`*U*"))))
- (repeat (sslength ss)
- (setq en (ssname ss 0))
- (setq blockname (_EFName en))
- (princ "\nThe rest of your code")
- (print blockname)
- (ssdel (ssname ss 0) ss)
- )
- )(princ)
- )
1.MSasu中的“SelectBlock”lisp(稍微调整)
- (defun SelectBlocks( / ssetBlocks ) ;;by MSasu, see earlier post in this thread.
- (setq ssetBlocks (ssget "_A" '((0 . "INSERT") (2 . "ELECT_TRANSFORMR_BANK_POINT,`*U*"))))
- (if ssetBlocks
- (if (= (getvar "CMDACTIVE") 0)
- (sssetfirst nil ssetBlocks) ;return on command prompt
- ssetBlocks ;return on select prompt
- ) ;end if
- (princ) ;return silent if no items to match filter
- ) ;end if
- ) ;end defun
2.从pBe获取块的有效名称
- defun c:test (/ssetBlocks en) ;;I think this will only get the effective name one at a time, so I added some ideas to make the lisp go through the entire list and get the effective name of each block selected.
- (defun _EFName (ent)
- (vl-load-com)
- (vla-get-effectivename (vlax-ename->vla-object ent)));; I think I need to add something like this
- (setq cntr 0) (ssname ssetBlocks 0) so that the effective name lisp looks at each entity individually, but I am not sure if ssname is the correct command to use.
- (if (ssetBlocks)) ;; I put the selection set variable from “selectblocks” where the selection filter used to be.
- (repeat (sslength ssetBlocks)
3.从选择集中筛选出与“elect\u transformr\u bank\u point”不匹配的任何有效名称
程序
- if (setq en (ssname ssetBlocks 0)) ;;If the name of the first entity is “ELECT_TRANSFORMR_BANK_POINT” I want to keep it, otherwise I want to delete it from the selection set.
- Then (ssdel (en /= “ELECT_TRANSFORMR_BANK_POINT”))
- (setq cntr (+ cntr 1)) ;; at some point I need to add this so the lisp increments through the list created in ssetBlocks.
- (setq blockname (_EFName en)) );; this line was in the original code, but I’m not sure what it does.
- (princ "\nThe rest of your code"));; this line was in the original code, but I’m not sure what it does.
- (ssdel (ssname ss 0) ss);; this line was in the original code, but I’m not sure what it does.
- )
- )(princ)
- )
4.用块名称或有效名称“elect\u transformr\u bank\u point”创建剩余块的活动选择集。这一部分是从上面重复的,我想我只需要在例行程序中的一个例子。
正如你所看到的,这些想法从一些承诺(我希望)开始,然后变成与愿望联系在一起的疯狂想法。对这位苦苦挣扎的代码编写者有什么指导吗?有一天,我梦见自己在睡梦中吐出代码,醒来后发现自己自动操作了咖啡机,但我会从解决手头的任务开始。 |