robierzo 发表于 2022-7-6 07:33:09

创建块

你好我有一组项目,我需要创建一个块。我使用“命令”,但在创建块时删除项目。我想把它们作为普通元素留在屏幕上。
我能做些什么来确保他们在绘画元素中幸存下来???
当做
 

(command "_-block" nombre_bloque punto_insercion conjunto_elementos "")

Lee Mac 发表于 2022-7-6 07:44:21

从对象的副本创建块,或在基点处插入新创建的块。
 
值得思考的是:
 

;; Objects to Block-Lee Mac
;; Converts a selection of objects to a block reference.
;; Limited to non-attributed blocks.

(defun c:obj2blk ( / e i l n p s x )
   (if
       (and
         (setq s (ssget "_:L" '((-4 . "<NOT") (0 . "ATTDEF,VIEWPORT") (-4 . "NOT>"))))
         (progn
               (while
                   (not
                     (or (= "" (setq n (getstring t "\nSpecify Block Name <Anonymous>: ")))
                           (and
                               (snvalid n)
                               (null (tblsearch "BLOCK" n))
                           )
                     )
                   )
                   (princ "\nBlock name invalid or already exists.")
               )
               (if (= "" n)
                   (setq n "*U")
               )
               (setq p (getpoint "\nSpecify Base Point: "))
         )
       )
       (progn
         (entmake
               (list
                  '(0 . "BLOCK")
                   (cons 10 (trans p 1 0))
                   (cons 02 n)
                   (cons 70 (if (wcmatch n "`**") 1 0))
               )
         )
         (repeat (setq i (sslength s))
               (entmake (entget (setq e (ssname s (setq i (1- i))))))
               (if (= 1 (cdr (assoc 66 (entget e))))
                   (progn
                     (setq x (entnext e)
                           l (entgetx)
                     )
                     (while (/= "SEQEND" (cdr (assoc 0 l)))
                           (entmake l)
                           (setq x (entnext x)
                                 l (entgetx)
                           )
                     )
                     (entmake l)
                   )
               )
               (entdel e)
         )
         (if (setq n (entmake '((0 . "ENDBLK"))))
               (entmake
                   (list
                      '(0 . "INSERT")
                     (cons 02 n)
                     (cons 10 (trans p 1 0))
                   )
               )
         )
       )
   )
   (princ)
)

robierzo 发表于 2022-7-6 07:50:25

李,你好。非常非常棒。
谢谢,谢谢。。。。。。。。谢谢

Lee Mac 发表于 2022-7-6 07:51:31

欢迎你robierzo,我希望你能从代码中学习。

Dadgad 发表于 2022-7-6 07:59:20

欢迎来到论坛。
看来李已经替你保驾护航了,
所以你的手很好。
我从未使用过Autocad 2006,因此不确定您是否有此选项。
在最近的版本中,当使用BLOCK或WBLOCK命令时,有一个名为RETAIN的选项
这将创建块,并使定义对象保持其在图形中的原始状态。

David Bethel 发表于 2022-7-6 08:07:43

总是有_u。OOPS命令-大卫

robierzo 发表于 2022-7-6 08:10:03

嗨,爸爸。问题是,这个选项不知道如何将其放入代码中
(命令“_-block”nombre\u bloque punto\u insercion convento\u elementos”)
可能是一些系统变量。
 
嗨,李。麦克。首先,我知道命令“snvalid”的存在。
杰杰杰。渐渐地你走了。向所有人致意。

robierzo 发表于 2022-7-6 08:18:54

您好。李,你的动作很好,但有个问题。它保留了元素,但插入了一个块。我应该炸掉这个街区吗?。我们能做些什么来保留原始元素吗???

David Bethel 发表于 2022-7-6 08:24:31

你试过OOPS命令吗?
 


(command "_-block" nombre_bloque punto_insercion conjunto_elementos ""
      "_.OOPS")


 
-大卫

robierzo 发表于 2022-7-6 08:29:16

对不起,大卫。我不明白前面的答案。现在我明白了。我不知道这个选项:哎呀。
很好。问候并感谢你所做的一切。
页: [1] 2
查看完整版本: 创建块