SteveK 发表于 2022-7-6 14:23:43

图纸平面图

每个需要绘制大量调查计划的人,CP、DP、RP都有不同的效率方法。我讨厌输入@,
 

(defun C:BD(/ LEN DEGS MINS SECS)
(command "_.line" (getpoint "\nPick a starting point: ")

;And Copy this bit 100 times or so as necessary*******
      (strcat "@" (rtos (getreal "\nType Length: ")) "<"
       (if (= (setq DEGS (getstring "\nType Degrees: ")) "") "0" DEGS) "d"
       (if (= (setq MINS (getstring "\nType Minutes: ")) "") "0" MINS) "'"
       (if (= (setq SECS (getstring "\nType Seconds: ")) "") "0" SECS) "\""
          )
;******************************************

)
(princ))

Lee Mac 发表于 2022-7-6 14:27:50

非常感谢。

SteveK 发表于 2022-7-6 14:34:29

没问题-如果您需要解释代码的任何部分,只需大喊

Lee Mac 发表于 2022-7-6 14:39:10

是的,在我提出代码问题之前,我必须先花几个小时研究代码:-)
我面临的一个直接问题是,我通常有0度面向页面,但这段代码将其输出到右侧。这个集合在代码中的什么地方?我可以更改它吗?
那么非做什么?
助教。

SteveK 发表于 2022-7-6 14:40:16

 
我只是将度/分/秒的角度转换为弧度,并使用极性函数绘制点。因此,如果你想让0度垂直,只需将所有测量值移动(pi/2)rads(90度)。
 
 

(Setq zzz 0)
(command "_.line" (getpoint "\nPick a starting point: ")
    (while (/= zzz 3)
      (strcat "@" (rtos (getreal "\nType Length: ")) "<"
       (if (= (setq DEGS (getstring "\nType Degrees: ")) "") "0" DEGS) "d"
       (if (= (setq MINS (getstring "\nType Minutes: ")) "") "0" MINS) "'"
       (if (= (setq SECS (getstring "\nType Seconds: ")) "") "0" SECS) "\""
          )
      (setq zzz (+ zzz 1)))

 
 
 
 
忽略OSNAP,以便打印点准确。

Lee Mac 发表于 2022-7-6 14:46:31

再次感谢。这很方便,因为我之前得到了一些零长度的线。
我本应该问这个问题的同时还要问北纬0度的问题;极坐标逆时针计算,可以顺时针计算吗?我想可能是*-1,但那不起作用。。。
 
编辑:我很高兴你没有熬夜,-1起作用:
 

(defun c:test (/ pt len deg mIs Sec Ang)
(if (setq pt (getpoint "\nSelect Starting Point: "))
   (progn
   (command "_.line" "_non" pt)
   (while
       (and
         (not (initget 2))
         (setq len (getdist pt "\nSpecify Length: "))
         (or (setq deg (getreal "\nDegrees: ")) (setq deg 0.))
         (or (setq mIs (getreal "\nMinutes: ")) (setq mIs 0.))
         (or (setq Sec (getreal "\nSeconds: ")) (setq Sec 0.))
         (setq Ang (* pi (/ (+ deg (/ mIs 60.) (/ Sec 3600.)) 180.))
               pt (polar pt Ang len)))
       (command "_non" pt))
   (command "")))
(princ))
      

 
谢谢你的帮助李

SteveK 发表于 2022-7-6 14:50:21

这样不行吗?
 

(defun c:test (/ pt len deg mIs Sec Ang)
(if (setq pt (getpoint "\nSelect Starting Point: "))
   (progn
   (command "_.line" "_non" pt)
   (while
       (and
         (not (initget 2))
         (setq len (getdist pt "\nSpecify Length: "))
         (or (setq deg (getreal "\nDegrees: ")) (setq deg 0.))
         (or (setq mIs (getreal "\nMinutes: ")) (setq mIs 0.))
         (or (setq Sec (getreal "\nSeconds: ")) (setq Sec 0.))
         (setq Ang (* pi (/ (+ deg (/ mIs 60.) (/ Sec 3600.)) 180.))
               pt (polar pt (+ Ang (/ pi 2.)) len)))
       (command "_non" pt))
   (command "")))
(princ))

 
编辑,很好的一个伴侣。

Lee Mac 发表于 2022-7-6 14:54:16

另一种选择是查看ACAD系统变量AngBase和AngDir

CAB 发表于 2022-7-6 14:57:21

这些变量看起来确实是“-pi/2”和“*-1”的更好替代品。只是不太确定如何实现它们。
 
旁白:李,我已经仔细研究了你的代码,我认为这一切都有道理!至于我自己写的。。。
只是出于兴趣,关于我最初发布的代码,在我看来,不运行另一个命令(例如polar命令)就不可能运行while循环。这是真的吗?

SteveK 发表于 2022-7-6 15:02:35

 
好主意,我没想到。
 
 
例如,只需一个测试语句,您就可以有一段时间的时间来观察以下代码(我能想到的最好的示例):
 

(setq Ang (* pi (/ (+ deg (/ mIs 60.) (/ Sec 3600.)) 180.))
               pt (polar pt (+ (* Ang -1.) (/ pi 2.)) len)))

 
请注意,WHILE语句只包含一个test语句,如果返回nil,则该语句将退出循环。
页: [1] 2
查看完整版本: 图纸平面图