明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 529|回复: 7

[提问] 【求助】关于 “line”命令问题

[复制链接]
发表于 2020-5-31 22:06:42 | 显示全部楼层 |阅读模式
想法是按照固定斜率画直线,类似正交情况下,直线限定了水平和垂直,如何按照需要的斜率限定直线方向?做了个简单代码但是不成功,哪位大侠帮改下,谢了。
(defun c:ddan ( / ang )
(setq an (getangle "\n输入斜率: "))
(setq ang (atan  an))

(command "line"  @2000<ang )
  (princ)
)

发表于 2020-6-1 00:09:13 | 显示全部楼层
(defun c:ddan  (/ ang)
(setq ang (getstring "\n输入角度: "))
(command "line" pause  (strcat "@2000<" ang) "")
(princ)
)
发表于 2020-6-1 01:52:16 | 显示全部楼层
本帖最后由 lisperado 于 2020-6-1 01:56 编辑

也许我搞错?是指斜度吗? 因为 1/1=1或100%, (atan 1) 转换为45度。

command命令版
  1. (setq *slope%* 2.5); 默认值
  2. (defun c:ddan ( / ang n )
  3. (setq n (getreal (strcat "\n输入斜度 <"(rtos *slope%* 2 2)"%>? : ")))
  4. (setq *slope%* (if n n *slope%*))
  5. (command "LINE" "\\" (strcat "@2000<"(angtos (atan (* 1e-2 *slope%*) ) 1 8)))
  6. (princ)
  7. )


entmake版 2000长度是以X-axis做标准?
  1. (setq *slope%* 2.5); 默认值
  2. (defun c:ddan1 (/ ang n pt)
  3.   (and (setq n (getreal (strcat "\n输入斜度 <" (rtos *slope%* 2 2) "%>? : "))
  4.              *slope%* (if n n *slope%*)
  5.              )
  6.        (setq pt (getpoint "\n线起点 : "))
  7.        (setq ang (atan (* 1e-2 *slope%*)) pt (trans pt 1 0))
  8.        (entmake
  9.          (list '(0 . "LINE") (cons 10 pt) (cons 11 (polar pt ang (abs (/ 2000. (cos ang))))) )
  10.          )
  11.        )
  12.   (princ)
  13. )

 楼主| 发表于 2020-6-1 07:51:14 | 显示全部楼层
非常感谢您的回复,确实是用斜度,三楼两个都好用。2000长度只是假定值,如果长度为变量,第二点是用光标选择完成的,类似正交选择时,可以吗?
发表于 2020-6-1 16:17:41 | 显示全部楼层
可以直接以 “<30" 度这样去响应line命令的,所以按你的梯度输入值反过来算出角度的弧度值,然后转换为角度值。
 楼主| 发表于 2020-6-1 20:49:52 | 显示全部楼层
如果已知角度可以直接用line命令,但是多数时候是坡度**%,直接命令还需要换算角度再输入,那就非常麻烦了,上面的代码已经非常好用了,我的思想就是坡度自动换算角度,然后line命令,非常感谢。
 楼主| 发表于 2020-6-1 20:54:37 | 显示全部楼层
再请教个问题,尺寸标注命令后(command "dimaligned" pp1 pp2  pt3),还想对标注这个尺寸进行编辑,怎样知道这个标注的列表呢,或使这个标注为被选择状态,或是知道它的名称。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-17 23:59 , Processed in 0.150045 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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