明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 986|回复: 0

[推荐]CALCS 2D DISTANCE IN ANY PLANE

[复制链接]
发表于 2007-2-11 14:21 | 显示全部楼层 |阅读模式

;CALCS 2D DISTANCE IN ANY PLANE

(defun c:di ();( / DF LOGSLD ID X Y Z ANS_IS PT1X PT1Y PT2X PT2Y PT1Z PT2Z DIS PT1 PT2)
(sETVAR "CMDECHO" 0)
;********ERROR HANDLER**********************
(defun *Error* (msg)
  (if (/= msg "Function cancelled")
    (princ (strcat "\nError: " msg))
  )
(terpri)
                        
  (setq *error* olderr)       
  (princ)
)
(find_Dcl)
        (command "dist" "0,0" "0,0")
        (setq ID (load_dialog (strcat path "\\DI.dcl")))
        (if (not (new_dialog "gaze" ID)) (exit))
        (set_tile "X" (setq X "0")) 
        (set_tile "Y" (setq Y "0")) 
        (set_tile "Z" (setq Z "0")) 
        (if (= "1" X)(set_tile "X" "1"))
        (if (= "1" Y)(set_tile "Y" "1"))
        (if (= "1" Z)(set_tile "Z" "1"))
        (if (and (and (= "1" X)(= "1" Y))(= "1" Z))
        (progn
        (set_tile "X" "0")
        (Set_tile "Y" "0")
        ));end pro/if
        (setq x (dimx_tile "view")
              y (dimx_tile "view"))
        (start_image "view")
        (fill_image 0 0 220 220 248)
         (slide_image 0 0 x y (strcat path "\\lisps(DI)"))
        (end_image)
         (set_tile "error" "Leave at least one dimension on!")
        (setq x (get_tile "X"))       
        (setq z (get_tile "Z"))
        (setq y (get_tile "Y"))

        (action_tile   "accept"       "(specs)(done_dialog 1)" )
          (action_tile "cancel"       "(done_dialog 0)")
          (Setq ans_is (Start_dialog))
          (Start_dialog)
        (end_image)     
        (unload_dialog id)
        (princ)

(if (= (+ (+ (atoi x) (atoi y))(atoi z)) 3)
(alert "You must have at least one dimension toggled on!")
)


       
 ;SPECS


(if (<= (+ (+ (atoi x)(atoi y))(atoi z)) 2)
(if (= ans_is 1)
(progn
(SETQ PT1 (getpoint "\nSelect first point: "))
(setq pt2 (getpoint PT1 "\nSelect second point: "))
(while (and pt1 pt2)
(setq   pt1x 0
        pt2x 0
        pt1y 0
        pt2y 0
        pt1z 0
        pt2z 0
        )
(if (/= Y "1") (progn
(setq pt1y (cadr pt1))
(Setq pt2y (cadr pt2))
))
(if (/= X "1") (progn
(setq pt1x (car pt1))
(Setq pt2x (car pt2))
))
(if (/= Z "1")(progn
(setq pt1z (Car (cddr pt1)))
(setq pt2z (car (cddr pt2)))
))
(setq pt1 (list pt1x pt1y pt1z))
(setq pt2 (list pt2x pt2y pt2z))
(command "dist" pt1 pt2)
(setq dis (getvar "distance"))
(if (and (and (= Z "1")(= X "0"))(= Y "0"))
(prompt (strcat "\nThe XY distance for the points selected is " (rtos dis 2 4) " units")))
(if (and (and (= Y "1")(= X "0"))(= Z "0"))
(prompt (strcat "\nThe XZ distance for the points selected is " (rtos dis 2 4) " units")))
(if (and (and (= X "1")(= Y "0"))(= Z "0"))
(prompt (strcat "\nThe YZ distance for the points selected is " (rtos dis 2 4) " units")))
(if (and (and (= Y "1")(= X "1"))(= Z "0"))
(prompt (strcat "\nThe Z distance for the points selected is " (rtos dis 2 4) " units")))
(if (and (and (= Y "1")(= X "0"))(= Z "1"))
(prompt (strcat "\nThe X distance for the points selected is " (rtos dis 2 4) " units")))
(if (and (and (= Y "0")(= X "1"))(= Z "1"))
(prompt (strcat "\nThe Y distance for the points selected is " (rtos dis 2 4) " units")))
(if (and (and (= Y "0")(= X "0"))(= Z "0"))
(prompt (strcat "\nThe XYZ distance for the points selected is " (rtos dis 2 4) " units")))
(princ "\n \n")
(SETQ PT1 (getpoint "\nSelect first point (return to quit): "))
(if pt1
(setq pt2 (getpoint PT1 "\nSelect second point (return to quit): ")))
);end while
)
(princ "\n**Function Canceled by User"));end if
(princ "\n**Can't find distance with all dimensions toggled off!!")
);end if
(setvar "cmdecho" 1)
(princ)
)
;**************************************************************
;;;;;;;;;;;;;;;;;;;;SPECS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun specs ()
        (setq   x (list 0)
                y (list 0)
                z (list 0))
        (setq x (get_tile "X"))       
        (setq z (get_tile "Z"))
        (setq y (get_tile "Y"))
        )

di.dcl文件

gaze:   dialog {
        label= "DIMENSIONAL DISTANCE CALCULATOR";
        width=30;
        :row {
        : image {
                   key = "view";
                   width = 20;
                   height = 12;
                   alignment = centered;
                   }

   :boxed_column {
    width = 1;
    height = default;
    layout = vertical;
    label = "Select Dimensions To Be Toggled OFF";
    boxed = true;
    :toggle {
        width = 5;
        label = "X";
        mnemonic = "X";
        key = "X";
                }

    :toggle {
        width = 5;
        label = "Y";
        mnemonic = "Y";
        key = "Y";
                }

    :toggle {
        width = 5;
        label = "Z";
        mnemonic = "Z";
        key = "Z";
                }
}
}
         :row {
          alignment = centered;
          fixed_width = true;
           :button {
                   is_default=true;
                   label = "PICK";
                   key = "accept";
                   mnemonic = "P";
                  }
          :spacer {width = 2;}
         cancel_button;
         errtile;
    
        }
  }

 

 

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-18 06:59 , Processed in 0.159440 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表