明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1507|回复: 1

[讨论] 绘制台阶的程序,不知道那个数值设置有问题?请求帮忙。

[复制链接]
发表于 2013-3-8 14:37:34 | 显示全部楼层 |阅读模式
;;;1、以下为主程序:
(defun c:htj ()
  (setvar "cmdecho" 0)
  (dcl_htj)    ;调用对话框子程序
  (prin1)
  )
;;;定义对话框*************************************************************************
(defun dcl_htj ()
  (setq dcl_id (load_dialog
   "nskdcl.DCL"
   )
)
  (new_dialog "dcl_htj" dcl_id)
  (sub_htj_rb1)    ;调用子程序,展示默认SLD
  (set_tile "tj_right" "1")  ;预设第一组 L基本形
  (set_tile "tj_ww" "200")
  (set_tile "tj_gg" "150")  ;预设宽度
  (set_tile "tj_num" "6")
  (set_tile "tj_ll" "900")
  (set_tile "tj_hh" "1500")  ;预设高度
  (action_tile "tj_right" "(sub_htj_rb1)")
  (action_tile "tj_left" "(sub_htj_rb2)")
  (action_tile "tj_ww" "(sub_htj_ww)")
  (action_tile "tj_gg" "(sub_htj_gg)")
  (action_tile "tj_num" "(sub_htj_num)")
  (action_tile "tj_ll" "(sub_htj_ll)")
  (action_tile "tj_hh" "(sub_htj_hh)")

  (action_tile "accept" "(ok_htj)(done_dialog 1)")
  (setq dd (start_dialog))
  (if (= dd 1)
    (draw_hztj)
    )
  )

;;;定义显示台阶样式*************************************************************************
(defun sub_htj_rb1 ()   ;展示左侧
  (setq ddtype 1)
  (show_sld "tj_kimage" "htj_right")
  )
(defun sub_htj_rb2 ()   ;展示右侧
  (setq ddtype 2)
  (show_sld "tj_kimage" "htj_left")
  )

;;;定义台阶参数变化*************************************************************************
(defun sub_htj_ww ()   ;ww台阶宽度变化
  (set_tile
    "tj_ll"
    (rtos (* (atoi (get_tile "tj_ww") ) (- (atoi (get_tile "tj_num")) 1))))
  )
(defun sub_htj_gg ()   ;hh台阶高度变化
  (set_tile
    "tj_hh"
    (rtos (* (atoi (get_tile "tj_gg")) (atoi (get_tile "tj_num") ))
   
   )
    )
  )
(defun sub_htj_num ()   ;台阶数量变化
   (if (/= (- (atof (get_tile "tj_num")) (fix (atof (get_tile "tj_num"))))
        0
   )
    (progn
      (alert "台阶数量(n)不是整数,请重新输入")
     
      )
    (progn
      (set_tile "tj_ll"
  (rtos (* (atof (get_tile "tj_ww"))
    (atof (- (get_tile "tj_num") 1) )
    )
        
        )
)
      (set_tile
"tj_hh"
(rtos (* (atof (get_tile "tj_gg") ) (atof (get_tile "tj_num")) )
      
      )
)
     )
   )
  )
(defun sub_htj_ll ()   ;ll台阶总长变化
  (set_tile "tj_ww"
     (rtos (/ (atof (get_tile "tj_ll") )
       (- (atof (get_tile "tj_num") )1)
       )
   
    )
     )
  )
(defun sub_htj_hh ()   ;hh台阶总高变化
  (set_tile
    "tj_gg"
    (rtos (/ (atof (get_tile "tj_hh") ) (atof (get_tile "tj_num") ))
   
  )
    )
  )

;;;定义显示台阶样式子程序*************************************************************************
(defun show_sld (key sld)  ;两个自变量 key 与 sld
  (setq x (dimx_tile key))  ;取得图像的右下角x坐标
  (setq y (dimy_tile key))  ;取得图像的右下角y坐标
  (start_image key)   ;开始处理图像对象
  (fill_image 0 0 x y -2)  ;先以背景色填满图像
  (slide_image 0 0 x y sld)  ;展示幻灯片
  (end_image)    ;退出处理图像对象
  )



;;;传递参数*************************************************************************
(defun ok_htj ()
  (setq ww (atof (get_tile "tj_ww"))) ;取得对话框内的ww值
  (setq hh (atof (get_tile "tj_gg"))) ;取得对话框内的hh值
  (setq num (atof (get_tile "tj_num")))
  )

;;;定义绘图子程序*************************************************************************
(defun draw_hztj ()
  (setq www (* ww (+ num 1)))
  (setq hhh (* hh num))
  (setq ptbas pt1)
  (setq pt0 (getpoint "\n选择台阶<左下角点>:"))
  
  (if (= ddtype 1)
      (progn
     (command "pline" pt0)
  (repeat num
    (setq ptbas (polar ptbas (/ pi 2) hh))
    (command ptbas)
    (setq ptbas (polar ptbas 0 ww))
    (command ptbas)
  )
  (setq ptbas (polar ptbas (+ pi (/ pi 2)) hhh))
  (command ptbas)
  (command "c")
  (prin1)
)
  )
)



发表于 2013-3-8 19:00:06 | 显示全部楼层
错误:(atof (- (get_tile "tj_num") 1))
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-8-27 04:06 , Processed in 0.174540 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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