hunszab 发表于 2022-7-6 10:44:49

阻碍

大家好!
 
我想写一个autolisp函数,插入一个特定的块。
 
所以:插入->块->“myblock”+输入。
 
这就是我想从代码中做的,因为它必须做1000次。。。。
 
谢谢你的帮助!
 
(这与“_insert”命令有关…)

profcad 发表于 2022-7-6 10:54:59

给我们一些细节。
1、区块名称
2、比例因子
3、旋转角度
4、任何你想要插入的特定层。

hunszab 发表于 2022-7-6 11:13:03

 
例如:
1、区块名称:myblock
2、比例因子:在屏幕上指定
3、旋转:在屏幕上指定
 
或比例因子:1,1,1
旋转:0.0

alanjt 发表于 2022-7-6 11:16:36

快速示例。。。
 
(defun _InsertBlock (block x y / x y)
;; block - name of block
;; x   - X scale for block (nil for on-screen prompt)
;; y   - Y scale for block (nil for on-screen prompt)
;; Alan J. Thompson, 07.19.10
(if (or (tblsearch "BLOCK" block) (findfile (strcat block ".DWG")))
   (if (and (or x
                (setq x (cond ((getdist "\nSpecify X value <1.0>: "))
                              (1.)
                        )
                )
            )
            (or y
                (setq y (cond ((getdist (strcat "\nSpecify Y value <" (rtos x) ">: ")))
                              (x)
                        )
                )
            )
       )
   (command "_.-insert" block "_X" x "_Y" y)
   )
   (alert (strcat "Block: \"" block "\" cannot be found!"))
)
(princ)
)

(defun c:Test1 (/) (_InsertBlock "P6" nil nil) (princ))

(defun c:TEst2 (/) (_InsertBlock "P6" 1. 1.) (princ))

(defun c:TEst3 (/) (_InsertBlock "P6" 1. nil) (princ))

hunszab 发表于 2022-7-6 11:30:34

谢谢!
 
你能给我一些建议吗?我在哪里可以找到有关“_.-insert”命令的信息。
我刚找到“插入”。。。
 
我如何等待用户输入Lisp代码?
 
谢谢
 
 

alanjt 发表于 2022-7-6 11:41:42

_忽略语言更改
. 忽略重新定义的命令
-发出命令的命令行版本(如果可用)
 
实际上,这可能更适合你。。。
 
(defun _InsertBlock (block x y r / x y r)
;; block - name of block
;; x   - X scale for block (nil for on-screen prompt)
;; y   - Y scale for block (nil for on-screen prompt)
;; r   - rotation of block (nil for on-screen prompt)
;; Alan J. Thompson, 07.19.10
(if (or (tblsearch "BLOCK" block) (findfile (strcat block ".DWG")))
   (if (and (or x
                (setq x (cond ((getdist "\nSpecify X value <1.0>: "))
                              (1.)
                        )
                )
            )
            (or y
                (setq y (cond ((getdist (strcat "\nSpecify Y value <" (rtos x) ">: ")))
                              (x)
                        )
                )
            )
       )
   (progn
       (command "_.-insert" block "_X" x "_Y" y)
       (and r (command "_r" (angtos r)))
   )
   )
   (alert (strcat "Block: \"" block "\" cannot be found!"))
)
(princ)
)

(defun c:Test1 (/) (_InsertBlock "P6" nil nil nil) (princ))

(defun c:TEst2 (/) (_InsertBlock "P6" 1. 1. nil) (princ))

(defun c:TEst3 (/) (_InsertBlock "P6" nil nil pi) (princ))

hunszab 发表于 2022-7-6 11:46:25

你好
 
我想迭代这个命令,那么如何等待用户输入呢?
 
具体来说:我想插入我的块,直到用户说OK,就够了。
页: [1]
查看完整版本: 阻碍