au-s 发表于 2022-7-6 15:08:09

块的插入

你好
 
我这里有点Lisp程序,我需要帮助。
我使用DoSLIb,它有很多优点。
 
这是我的Lisp程序:
 
 

(defun c:INBLOCK ()
(setq sl (dos_getdir "Choose Block_Library" "K:\\CAD\\Blocks\\")) (dos_dwgpreview "Choose Block_Library" sl)
(setq p0 (getpoint "\nChoose insertion point: "))
(setvar "attdia" 1)
(command "-insert" sl p0 1 1 0)
(command "attdia" 0 "")
(princ)
)

 
如何插入选定的块?
它只要求我插入,然后什么也没有插入。
 
Thanx寻求帮助

au-s 发表于 2022-7-6 15:12:19

这就解决了:


(defun c:AIX:INBLOCK ( / sl)(setq sl nil)
(setq sl (dos_dwgpreview "Choose block" "K:\\CAD\\Block\\"))
(if sl (command "-insert" sl pause "1" "1" "0")
   (princ))
)

au-s 发表于 2022-7-6 15:15:44

我有一个小问题。。。
 
如果我运行此:
 
 

(defun c:INBLOCK ( / sl oldlay)
(setq oldlay (getvar "clayer"))
(setq sl nil)
(setvar "cmdecho" 0)
(if (not (tblsearch "LAYER" "A-------O2-"))
         (command "-layer" "M" "A-------O2-" "C" "red" "A-------O2-" "")
         (setvar "clayer" "A-------O2-")
         ) ; end if

(setq sl (dos_getdir "Choose symbols" "K:\\CAD\\Block"))(dos_dwgpreview "Choose symbols" sl)

(prompt "\nChoose point to insert ...")
(if sl (command "-insert" sl pause "1" "1" "0")

   (princ))(setvar "clayer" oldlay)
)

 
如果我取消该命令,则创建层A------O2。
我想要的是完全取消命令,以便lisp退出。
Thanx公司

Lee Mac 发表于 2022-7-6 15:18:31

层的创建是在程序暂停供用户输入之前进行的,因此层将在用户有机会取消任何操作之前创建

au-s 发表于 2022-7-6 15:21:56

我该怎么改变呢??
所以程序取消图层创建??

Lee Mac 发表于 2022-7-6 15:26:54

也许可以在“选择符号”部分使用IF语句,然后再创建层,这样如果用户取消“选择符号”部分,就不会创建层。

au-s 发表于 2022-7-6 15:30:34

thanx。。。
 
这就是我得到的:
 
;;;

(defun C:describe ()
;;;Do the mapcar function for each layer in the drawing.
(vlax-for layer
       (vla-get-layers
         (vla-get-activedocument
       (vlax-get-acad-object)
       )
         )
;;;if the current layer being checked matches a predetermined name, add the needed description.
   (mapcar
   (function
   (lambda (layname description)
   (if (= (strcase (vla-get-name layer)) (strcase layname))
       (vla-put-description layer description)
       ()
       )
   )
   )
   '("A-------O2-" ) ; This is your list of layers needing a description.
   '("arrow"); This is the descriptions for each layer.Make sure the order is EXACTLY the same as in the layer list.
   )
   )
(princ); Silent exit.
)

   (defun c:layercreation ()

       (if(tblsearch "LAYER" "A-------O2-")
(command "_layer" "s" "A-------O2-" "")
         (command "-layer" "M" "A-------O2-" "C" "red" "A-------O2-" "")
         
         ) ; end if
         
          );en defun
(defun c:inarrow ( / sl oldlay)
(setq oldlay (getvar "clayer"))
(setq sl nil)


(setq sl (dos_dwgpreview "Choose arrows" "K:\\CAD\\\\block\\arrows"))
(prompt "\nChoose insertion point")
(if sl
   (progn
   (c:layercreation)
   (c:describe)
   (setvar "clayer" "A-------O2-")
   (command "-insert" sl pause "1" "1" "0")
   (setvar "clayer" oldlay)

   
);progn

   );if
(exit)

)
 
Dos_dwgpreview有一个浏览按钮。
我不知道我是否可以禁用它。
这里的用户可以选择浏览到其他文件夹并选择其他块。
如果他这样做,那层仍然是一个----O2-。
如果不能禁用浏览按钮,我想要的是,如果用户选择转到另一个路径,或者层改为------O4-的路径。
这我做不到
 
我不知道怎么做。。什么是智能。
我有文件夹:

在此情况下:


标度符号
汽车
 
每一个都是layerdependent。
 
汽车以一种------O1的形式出现-
人们可能在--------10-
 
在lisp上方插入一个带有层A的箭头------O2-。。。
我想如果用户更改目录,它会将一层添加到该目录中。。。
 
这很难做到吗?
 
Thanx公司

Lee Mac 发表于 2022-7-6 15:34:08

我将函数“descripe”和“layercreation”定义为局部函数,即。
 

(defun describe...

 
而不是
 

(defun c:describe...

 
然后通过以下方式调用它们:
 

(describe)

 
而不是
 

(c:describe)

au-s 发表于 2022-7-6 15:36:50

thanx。。
 
路径解决方案。。。
有可能做一个条件吗?
就像这个lisp只在指定的路径中工作一样?如果用户浏览到条件中未指定的另一个路径,它将提醒用户。
 
我认为这更容易。。。
这是一个好方法吗?
 
非常感谢。

Lee Mac 发表于 2022-7-6 15:38:49

我不太确定如何使用代码中的“dos”元素
页: [1] 2
查看完整版本: 块的插入