Verticalmojo#2 发表于 2012-1-24 15:03:52

用另一个具有属性的块替换块

你好!
有没有办法用另一个块替换一个块并传输新属性,而无需同步?我想保留现有属性的位置...同步会将属性放回原始方向......
提前谢谢...
**** Hidden Message *****

ronjonp 发表于 2012-1-24 16:58:09

新块是否具有与旧块相同的属性和标签?如果是这样,我认为您可以重新定义块。

Rob... 发表于 2012-1-24 19:42:30

回答得好。

danAllen 发表于 2012-1-24 21:24:27

请从这里尝试这一项:
http://forums . Autodesk . com/t5/Visual-LISP-AutoLISP-and-General/imredoms/TD-p/806704/page/2

REPLACE.LSP - (Block Replace) - (c) 1990 Richard D. Howard
all rights reserved - no warranty, express or implied
The included files may be used and copied for non-profit
purposes only. If you wish to include any of the files in a
commercial program, contact the author.
---------------
REPLACE, replaces selected blocks with a specified block,
retaining all of the original properties. REPLACE handles blocks
with attribute data correctly, and can optionally allow entry of
new attributes at runtime. This makes REPLACE ideal for updating
blocks whose definition has changed (AutoCAD does not updates the
attributes in such instances). When replacing attributes, REPLACE
actually erases the old block and substitutes the new one
retaining as much of the former data as possible. The two fields
that are definately modified are "entity name", and "handle
number" (because the block really is new). If you require these
to remain the same, don't use REPLACE. If no attributes are
present, REPLACE simply updates the name attached to the original
block insert. This retains ALL the inserts data, including the
entity name and handle.

Verticalmojo#2 发表于 2012-1-25 12:59:27

不,帖子中的lisp是由Richard D. Howard撰写的,如果名称相同,将保留属性

danAllen 发表于 2012-1-25 13:13:17

好久不见了,魔咒!欢迎回来陌生人。

mark 发表于 2012-1-25 13:15:25

今天早些时候我试着发帖,但没能到沼泽地…很高兴看到它又开始工作了
我可能没有正确理解,但express工具也做了同样的事情。如果新块具有额外属性,而我替换了旧块,则信息传输很好,但需要重新定义块以显示额外属性。这会导致块及其属性失去其位置…我必须重新定位所有东西,对我来说,超过1000个块,每个块有6个属性…啊!如果我能把它简化为只需移动一个属性,那将是非常棒的….
你好,马克!谢谢很高兴回来。你能把我原始账户的密码发给我吗verticalmojo@gmail? 似乎当我尝试重置时,它会将其发送到@Swarm。org电子邮件,我以前用过,我不确定它是否存在,如果存在,我也不知道如何进入它。不用急,只要你有机会…谢谢!

Verticalmojo#2 发表于 2012-1-25 18:21:29

不是最漂亮的东西,但试一试。请记住,这只会查看插入点,并尝试将它们放置在找到的原始位置。
玩得开心
(defun c:attsync2 (/ _name _gettatts _lst atts e name ss)
(defun _lst (ss / e n out)
    (setq n -1)
    (if        (= (type ss) 'pickset)
      (while (setq e (ssname ss (setq n (1+ n)))) (setq out (cons (vlax-ename->vla-object e) out)))
    )
)
(defun _attpositions (block / att result)
    (foreach att (vlax-invoke block 'getattributes)
      (setq result (cons (list (vla-get-handle att)
                             (vlax-get att 'insertionpoint)
                             (vlax-get att 'textalignmentpoint)
                       )
                       result
                   )
      )
    )
)
(defun _name (b)
    (cond ((vlax-property-available-p b 'effectivename) (vla-get-effectivename b))
          ((vlax-property-available-p b 'name) (vla-get-name b))
    )
)
(if (and (setq e (car (entsel "\nSelect block to sync: ")))
           (setq name (_name (vlax-ename->vla-object e)))
           (setq ss (ssget "_x" (list (cons 0 "insert"))))
      )
    (progn (foreach x (_lst ss) (and (eq (_name x) name) (setq atts (cons (_attpositions x) atts))))
           (command "._attsync" "_s" e "_yes")
           (foreach x (apply 'append atts)
             (if (and (setq e (handent (car x))) (setq e (vlax-ename->vla-object e)))
             (progn (vl-catch-all-apply 'vlax-put (list e 'insertionpoint (cadr x)))
                      (vl-catch-all-apply 'vlax-put (list e 'textalignmentpoint (caddr x)))
             )
             )
           )
    )
)
(princ)
)

ronjonp 发表于 2012-1-25 19:35:37


你是正确的,我的错误,我误解了你的要求。

danAllen 发表于 2012-1-26 01:13:17


试试看。
页: [1] 2
查看完整版本: 用另一个具有属性的块替换块