ssg 发表于 2022-7-5 12:55:11

我可以通过entm创建新层吗

我通常通过命令功能创建新层。例子:
(命令“Layer”“N”MyLayer“L”MyLtype MyLayer“C”MyColor MyLayer“T”MyLayer“”)
我想用entmake函数来做。有人能帮我吗?
提前感谢!

VovKa 发表于 2022-7-5 13:02:27


(entmake (list (cons 0 "LAYER")
       (cons 100 "AcDbSymbolTableRecord")
       (cons 100 "AcDbLayerTableRecord")
       (cons 2 MyLayer)
       (cons 6 MyLtype)
       (cons 62 MyColor)
)
)

阅读DXF参考了解更多组码

ssg 发表于 2022-7-5 13:05:54

谢谢!
你的Lisp程序很专业!

kpblc 发表于 2022-7-5 13:11:48

如果dwg中存在图层MyLayer,则会收到错误。您最好这样使用smth:
(defun create-my-layer (name ltype color / res)
                      ;|
*    Creates a new layer in current dwg.
* If layer exist, returns an ename-pointer to it (no changes). If not, layer
* has been tried to create with settings.
*    Call parameters:
name        Name of layer
ltype        Name of linetype setted to created layer. If it doesn't exist
        the linetype "Continuous" will be used
color        ICA-color for creating layer
|;
(cond
   ((tblobjname "layer" "name"))
   (t
    (setq res (entmakex (list (cons 0 "LAYER")
                              (cons 100 "AcDbSymbolTableRecord")
                              (cons 100 "AcDbLayerTableRecord")
                              (cons 2 name)
                              (cons 6
                                    (cond ((tblobjname "ltype" ltype))
                                          (t "Continuous")
                                          ) ;_ end of cond
                                    ) ;_ end of cons
                              (cons 62 color)
                              ) ;_ end of list
                        ) ;_ end of entmakex
          ) ;_ end of setq
    )
   ) ;_ end of cond
) ;_ end of defun

fuccaro 发表于 2022-7-5 13:16:56

Ssg公司
你需要一层来放置一些东西,对吗?
为什么不在需要的图层上创建所需的对象;如果层存在-将使用它,如果不存在-将创建它。

ssg 发表于 2022-7-5 13:19:31

@kpblc:谢谢!我知道如何使用条件函数:if,cond…。我将在特定情况下添加它们。
 
@fuccaro:是的,但有时我需要创建没有任何对象的新层(使用自定义标准创建模板图形时)。
 
谢谢大家!你的想法对我很有用。但还有一个问题:
当我创建普通实体(直线、圆、圆弧…)时,我不需要DXF代码100。
例子:
(entmake(列表(cons 0“行”)(cons 10’(100 100))(cons 11’(150 200)))
 
AutoCAD应用程序将自动将它们添加到实体数据库中:AcDbEntity、AcDbLine、AcDbArc、AcDbCircle。
 
但为什么我必须声明DXF代码100与层(可能与表组中的所有对象)?例子:
(entmake(列表(cons 0“层”)
(cons 100“AcDbSymbolTableRecord”)
(cons 100“AcDbLayerTableRecord”)
(cons 2“MyLayer”)
(cons 70 0)
)
 
如果其中一个丢失,则不会创建新层。
谁能解释?

Bilal 发表于 2022-7-5 13:24:02


(defun create-my-layer (name ltype color / res)
                      ;|
*    Creates a new layer in current dwg.
* If layer exist, returns an ename-pointer to it (no changes). If not, layer
* has been tried to create with settings.
*    Call parameters:
name        Name of layer
ltype        Name of linetype setted to created layer. If it doesn't exist
        the linetype "Continuous" will be used
color        ICA-color for creating layer
|;
(cond
((tblobjname "layer" name))
(t
(setq res (entmake (list (cons 0 "LAYER")
                                     (cons 100 "AcDbSymbolTableRecord")
                                     (cons 100 "AcDbLayerTableRecord")
                                     (cons 2 name)
                                     (cons 70 0)
                                     (cons 62 color)
                                     (cons 6
                                           (cond ((tblobjname "ltype" ltype) ltype)
                                                    (t "Continuous")
                                    ) ;_ end of cond
                                     ) ;_ end of cons
                     ) ;_ end of list
            ) ;_ end of entmake
   ) ;_ end of setq
)
) ;_ end of cond

) ;_end of defun

ronjonp 发表于 2022-7-5 13:27:40

这里还有一个可以让你添加图层描述的。。。哎呀。。才意识到这条线已经有10年了

pBe 发表于 2022-7-5 13:35:24

僵尸警报

ronjonp 发表于 2022-7-5 13:37:46

*>>*
页: [1] 2
查看完整版本: 我可以通过entm创建新层吗