[LISP]仅缩放“x”an
嘿我希望编写一个lisp例程,其中包括创建一个块并在x和y方向(而不是z方向)缩放它(这是客户端坐标转换的要求)。。。我还没弄明白。
我的想法是在命令中添加一种中断,用户可以单击块并手动更改比例,但我不知道如何添加这种中断。以下是我的尝试:
(DEFUN C:CC ()
(COMMAND
"_.SCALE"
"_ALL"
""
'(0 0)
3.28084
"_BLOCK"
"1"
'(0 0)
"_ALL"
""
(prompt "change x and y scale of block to 1.025")
break
"_.explode"
)
)
任何帮助都将不胜感激。
谢谢
CR公司 像这样的怎么样?
(defun c:cc ( / newscl)
(setq blk (car (entsel "\nSelect the block to change the X and Y to 1.025 : ")))
(setq newscl 1.025)
(entmod
(subst
(cons 41 newscl)
(assoc 41 (entget blk))
(entget blk)
)
)
(entmod
(subst
(cons 42 newscl)
(assoc 42 (entget blk))
(entget blk)
)
)
(entupd blk)
(princ)
)
你希望所有的东西都先从公制缩放到英制,还是仅仅是块?不管怎样,我都会单独运行。
在中断时,您是否希望允许用户手动覆盖1.025默认值?
我希望所有的东西都先缩放。
我正在寻找用户以某种方式选择创建的块实体,并在不缩放z的情况下缩放x轴和y轴。目前我知道的唯一方法是将轮廓制作成块,通过属性缩放x轴和y轴,然后分解块。
此外,如果你能逐行了解每个命令的含义以及你决定走这条路的原因。。。这里是初学者。
谢谢
CR公司 CheSyn,您可以将代码缩短为以下内容。此外,最好使用if函数检查none nil返回值
从第一个变量。
(defun c:Test (/ blk newscl)
(if (setq blk (car (entsel "\nSelect the block to change the X and Y to 1.025 : ")))
(entmod (append (entget blk)
(list (cons 41 1.025) (cons 42 1.025))
)))
(princ)
)
谢谢塔瓦的提醒!我还为if函数添加了一个提示。
我没有意识到append和list可以与entmod结合使用;看起来干净多了。是否有首选“subst”的时间/地点,如果是,为什么/在哪里?
Chiimayred,我在下面附上了一些评论。我仍然觉得从公制到英制的缩放最好在单独的命令中完成。现在,该块将在命令完成后爆炸。
(defun c:cc ( / blk newscl)
(if
(setq blk (car (entsel "\nSelect the block to change : ")))
(progn
(setq newscl
(getreal ; set newscl as a real number
(strcat "\nSpecify the scale factor < 1.025 > : "); string prompt
)
)
(if ; if newscl does not have a value associated with it, set the value as 1.025
(=
nil
newscl
)
(setq newscl 1.025)
)
(entmod ; modifies the properties of the entity
(append ; combines the list
(entget blk); indicates what entity to edit
(list ; create a list of properties to change
(cons 41 newscl)
(cons 42 newscl)
)
)
)
(entupd blk); updates the block
(command "_.explode" blk "")
)
(prompt "\nNo selection made!")
)
(princ)
)
我想我可能被误解了。
在缩放图形后,我将整个图形制作成一个块。因此,我不需要选择块,因为整个图形是一个块。我正在寻找一种方法来缩放该块的X轴和Y轴,因为在转换过程中,Z不能在这一点上缩放。
我不太明白41号和42号是怎么做到的,但这似乎是可行的。
我只需要找出如何选择一个块,缩放cons 41和cons 42,然后分解并清除块。
谢谢
CR公司
不客气。
每个函数都有自己的性能,我使用了append函数,因为我有多个替代dxf代码来
否则我会立即使用subst函数。 Tharwat对LISP有些陌生,我担心使用列表。看看它们有多有用,我会更深入地研究它们。
Chiimayred、cons 41和42指的是DXF代码41和42。DXF 41表示X比例,DXF 42表示Y比例,DXF 43表示Z比例。我没有包括DXF 43,因为你不想改变它。
您希望添加/更改发布的LISP中具体缺少什么?
谢谢Chesyn,我将不得不研究DXF代码。
与其从用户那里获取输入,不如直接选择创建的块并缩放它。
谢谢你们到目前为止的帮助
CR公司 如果这是你要找的,请告诉我。
(defun c:cc ( / sset blk newscl)
(if
(setq sset (ssget "_x" (list '(0 . "INSERT") (cons 410 (getvar "ctab")))))
(progn
(setq blk (ssname sset 0))
(entmod ; modifies the properties of the entity
(append ; combines the list
(entget blk); indicates what entity to edit
(list ; create a list of properties to change
(cons 41 1.025)
(cons 42 1.025)
)
)
)
(entupd blk); updates the block
(command "_.explode" blk "")
)
(prompt "\nNo blocks in drawing!")
)
(princ)
)
页:
[1]
2