明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 823|回复: 4

[提问] 返回值“输入斜边长度参数类型错误”,请问大神这个代码哪里出错了?

[复制链接]
发表于 2022-5-27 23:27:31 | 显示全部楼层 |阅读模式
(defun c:443 ()
(setq pp1 (getpoint "输入左下角一点"))
(setq ww (getdist pp1 "\n 输入底边长度"))
(setq pp2 (polar pp1 0 ww))
(setq ww2 (getdist pp2 "\n 输入斜边长度"))
(setq ww3(sqrt (- (* ww2 ww2) (* ww1 ww1))))
(setq pp3 (polar pp1 (/ pi 2) ww3))
(command "line" pp1 pp2 pp3 "c")
(prin1)

发表于 2022-5-27 23:55:26 | 显示全部楼层
(defun c:443 ()
  (setq pp1 (getpoint "输入左下角一点"))
  (setq ww1 (getdist pp1 "\n 输入底边长度"))
  (setq pp2 (polar pp1 0 ww))
  (setq ww2 (getdist pp2 "\n 输入斜边长度"))
  (setq ww3 (sqrt (- (* ww2 ww2) (* ww1 ww1))));注意不要是负数
  (setq pp3 (polar pp1 (/ pi 2) ww3))
  (command "line" pp1 pp2 pp3 "c")
  (prin1)
)
发表于 2022-5-28 10:05:24 来自手机 | 显示全部楼层
三角函数问题,要控制斜边ww2大于底边ww长度,加个判断语句
 楼主| 发表于 2022-5-28 12:51:27 | 显示全部楼层
tigcat 发表于 2022-5-27 23:55
(defun c:443 ()
  (setq pp1 (getpoint "输入左下角一点"))
  (setq ww1 (getdist pp1 "\n 输入底边长度 ...

谢谢    ,,,,,
发表于 2022-5-28 13:21:48 | 显示全部楼层
  1. (defun c:tt ()
  2. (defun Udist (bit kwd msg def bpt / inp)
  3.   (if def
  4.     (setq msg (strcat "\n" msg "<" (rtos def) ">: ")bit (* 2 (fix (/ bit 2))))
  5.     (setq msg (strcat "\n" msg ": "))
  6.   )
  7.   (initget bit kwd)
  8.   (setq inp (if bpt(getdist msg bpt)(getdist msg)))
  9.   (if inp inp def)
  10. )
  11.   (setq w1(Udist 7 "" "底边长度<输入或鼠标直接量取>" w1 nil))
  12.   (setq w2(Udist 7 "" "斜边长度<输入或鼠标直接量取>" w2 nil))
  13.    (while (setq p1 (getpoint "\n输入左下角<退出>: "))
  14.      (setq p2 (polar p1 0 ww))
  15.      (setq w3 (sqrt (- (* w2 w2) (* w1 w1))))
  16.      (setq p3 (polar p2 (/ pi 2) w3))
  17.      (command "pline" p1 p2 p3 "c")
  18.    )
  19.   (princ)
  20. )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-29 15:18 , Processed in 0.140169 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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