Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lisp 获取拉伸的测量值_Lisp_Autocad_Stretch_Autocad Plugin_Autolisp - Fatal编程技术网

Lisp 获取拉伸的测量值

Lisp 获取拉伸的测量值,lisp,autocad,stretch,autocad-plugin,autolisp,Lisp,Autocad,Stretch,Autocad Plugin,Autolisp,我正在创建一个算法来帮助我将框扩展到正确的大小,例如: 我编写了一个代码,询问两个应该是新深度的点,并测量它们。然后减去块的原始深度(0.51),然后要求侧边拉伸 (defun mystretchh ( dis / pt1 pt2 sel ) (while (and (setq pt1 (getpoint "\nFirst point of selection window: ")) (setq pt2 (getcorne

我正在创建一个算法来帮助我将框扩展到正确的大小,例如:

我编写了一个代码,询问两个应该是新深度的点,并测量它们。然后减去块的原始深度(
0.51
),然后要求侧边拉伸

(defun mystretchh ( dis / pt1 pt2 sel )
    (while
        (and
            (setq pt1 (getpoint "\nFirst point of selection window: "))
            (setq pt2 (getcorner pt1 "\nSecond point of selection window: "))
            (not (setq sel (ssget "_C" pt1 pt2)))
        )
        (princ "\nNo objects where found in the selection window.")
    )
    (if sel
        (progn
            (command "_.stretch" sel "" "_non" '(0 0) "_non" (list dis 0))
            t
        )
    )
)
(defun c:test (/ a x c p)
;ungroup
(command "pickstyle" 0)
;variables
(initget (+ 1 2 4))
(setq p (getpoint "\nSelect first point: "))
(setq c (getpoint "\nSelect second point: "))
(command "_.dist" p c)
(setq x (rtos (getvar 'distance) 2 3))


    ;calculate distance to stretch
    (setq a (- x 0.51))


    ;stretch
    (mystretchh a)

    ;regroup
    (command "pickstyle" 1)
    (print "Module modified.")
    (princ)
)
我有两个问题:

  • 拉伸是反向进行的,我尝试使用负值,但没有效果
  • 它报告了一个语法错误,但我找不到它
    我已经半年没有接触AutoLISP了-也许你们中的一些人可以在一眨眼之间发现问题。

    您可以使用标准函数计算两点之间的距离,而不是调用命令然后检索系统变量的值

    因此,这:

    (command "_.dist" p c)
    (setq x (rtos (getvar 'distance) 2 3))
    
    可以成为:

    (setq x (rtos (distance p c) 2 3))
    
    (setq a (- (distance p c) 0.51))
    
    但是,您收到一个语法错误,因为您已使用将距离转换为字符串,然后尝试在此处对字符串执行算术运算:

    (setq a (- x 0.51))
    
    无需将距离转换为字符串,因此这些表达式可以变成:

    (setq x (rtos (distance p c) 2 3))
    
    (setq a (- (distance p c) 0.51))
    
    在执行此减法之前,您可能还需要检查
    (距离pc)
    是否大于
    0.51
    ,以避免意外结果

    要确定适当的方向,由于当前代码只能沿x轴拉伸,因此需要检查点
    p
    的x坐标是否大于点
    c
    的x坐标