Lee Mac 发表于 2022-7-6 15:05:27

老实说,我相信他们真的应该教会我们从小就考虑弧度。
 
角度测量是一个任意系统,仅在360具有很多因素时才真正使用,因此可以在许多情况下使用,而无需十进制计算。就像梯度角度测量一样,其中100grads是一个直角-一个任意的概念,为便于使用而引入*。
 
但是,当涉及到弧长和段面积计算时,使用弧度作为一种测量形式使生活变得更加简单,更不用说大多数几何证明仅适用于弧度θ。
 
无论如何,这只是我对它的看法-只是从工作时必须完全使用弧度系统的经验来看-以及如何很容易滑回到以度为单位的思考,因为它深深地植根于我们对角度的理解中。
 
 
*我可以补充一点,这些形式的测量确实有其历史,并且不仅仅是为了数字中的因子数量而引入的,但这只是使用该系统的另一个动机。

MarcoW 发表于 2022-7-6 15:11:00

在我看来:以上信息对我来说太多了。我刚刚学会了如何正确计算几点。关于弧度的事情我无法永远避免,所以我想稍后会发生。
 
一个快速问题“关于主题”。。。想象一下,我想。pline从pt3到pt4等。pline命令结束时,我想画一个圆,比如在pt3上画一个直径为dia1的圆。
首先,我会在例程的某个地方提示输入直径,有点像这样:
 
(setq dia1 (getint "\nDiameter of cicle"))
 
当命令pline结束时,我想画一个圆:
 
(command "circle" pt3 "d" dia1)
 
所以让我们把它融化在一起:
 
(defun c:box1(/ oldos len leng dist pt1 pt2 pt3 pt4 pt5 pt6)

(setq oldos (getvar "OSMODE"); Collect Old OSMODE setting

; Define Functions and Localise Variables

       len(getdist "\nLength1:")
      
       leng (getdist "\nLength2:")

       dia1 (getint "\nDiameter of cicle:")

       ; I'd be more inclined to use "getdist"
       ; so that the user can pick the distance.
      
       dist (getdist "\nDistance:")
      
       pt1(getpoint "\nInsertion:")
      
       pt2(polar pt1 (* pi 0.5) dist)
      

;;;                     + pt2
;;;                     |
;;;                     |
;;;                     + pt1

      
       pt3(polar pt2 pi (* len 0.5))
      

;;;            +--------+ pt2
;;;         pt3       |
;;;                     |
;;;                     + pt1
      
      
       pt4(polar pt3 (* pi 0.5) leng)

      
;;;         pt4
;;;            +
;;;            |
;;;            |
;;;            +--------+ pt2
;;;         pt3       |
;;;                     |
;;;                     + pt1
      
      
       pt5(polar pt4 0.0 len)
      

;;;         pt4               pt5
;;;            +-----------------+
;;;            |
;;;            |       pt2
;;;            +--------+--------+
;;;         pt3       |       pt6
;;;                     |
;;;                     + pt1
      
      
       pt6(polar pt3 0.0 len)

       ); End Setq

(setvar "OSMODE" 0); Turn off the OSnaps!

(command "_.pline" pt3 pt4 pt5 pt6 pt3 "")

; Remember to use "_." prefix to make it
; compatible for all language versions.

(command "_.rotate" (entlast) "" pt1 pause)
(command "circle" pt3 "d" dia1)

; Use "entlast" to detect last entity
; added to database (hence created).

(setvar "OSMODE" oldos); Turn OSMODE back on

(princ)

; Exit Cleanly

) ; End box1
 
然后它就不起作用了,因为entlast将最后一个实体添加到数据库中(因此创建)。因此,绘制圆,但不随长方体旋转。
 
顺便问一下,“因此而生”是什么意思。?
 
恐怕我能坚持很久了……:下一件事。
当查看此命令时,结果是绘制的实体(或者我必须说是因此创建的实体)。我的意思是,它是由线条、普林斯等组成的。
结果是否可能相同(显示),但它是一个块?因为如果它是一个块,它可能有属性。属性可以用给定的值填充。
 
例如,框1:100x100 dist50 circle 10等等,生成所需的框,属性为100-100-10(我想要的任何内容)。
 
或者是“怪人:”这样想?

MarcoW 发表于 2022-7-6 15:13:58

请在这之前阅读我的帖子,它包含375个问题:-)
---
“与此同时”
---
我不得不修改它,使盒子旋转得更自然(至少对我来说是这样),方向是十字线移动的方向。对于那些得到它的人来说,这并不困难,对我来说,这是相当汗流浃背的,但我设法做到了:
 
(defun c:box99(/ oldos len leng dist pt1 pt2 pt3 pt4 pt5 pt6)

(setq oldos (getvar "OSMODE"); Collect Old OSMODE setting

; Define Functions and Localise Variables

       len(getdist "\nBox length:")
      
       leng (getdist "\nBox with:")

       ; I'd be more inclined to use "getdist"
       ; so that the user can pick the distance.
      
       dist (getdist "\nDistance between box and insertion point:")
      
       pt1(getpoint "\nInsertion point:")
      
       pt2(polar pt1 0.0 dist)
      

;;;                     +-------+
;;;                        pt1        pt2

      
       pt3(polar pt2 (* pi 0.5) (* len 0.5))
      
;;;
;;;
;;;                                pt3
;;;                                +
;;;                                |
;;;                                |
;;;                     +-------+
;;;                        pt1        pt2
;;;

      
      
       pt4(polar pt3 0.0 leng)

      
;;;
;;;
;;;                             pt3    pt4
;;;                                +---+
;;;                                |
;;;                                |
;;;                     +-------+
;;;                        pt1        pt2
;;;
      
      
       pt5(polar pt4 (* pi 1.5) len)
      

;;;
;;;
;;;                             pt3    pt4
;;;                                +---+
;;;                                |   |
;;;                                |   |
;;;                     +-------+   |
;;;                        pt1        pt2 |
;;;                                  |
;;;                                  +
;;;                                   pt5
      
      pt6(polar pt5 pi leng)

;;;
;;;
;;;                             pt3    pt4
;;;                                +---+
;;;                                |   |
;;;                                |   |
;;;                     +-------+   |
;;;                        pt1        pt2 |
;;;                                  |
;;;                                +---+
;;;                              pt6   pt5


       ); End Setq

(setvar "OSMODE" 0); Turn off the OSnaps!
(setvar "ORTHOMODE" 1); Turn on ORTHO

(command "_.pline" pt3 pt4 pt5 pt6 pt3 pt5 "")


; Remember to use "_." prefix to make it
; compatible for all language versions.

(command "_.rotate" (entlast) "" pt1 pause)

; Use "entlast" to detect last entity
; added to database (hence created).

(setvar "OSMODE" oldos); Turn OSMODE back on

(princ)

; Exit Cleanly

) ; End box99
 
所以这个我更喜欢。接下来我要做的是,第二次调用box99时,它必须“提议”第一次给定的length/with/dist。
 
我想这与initget和关键字有关,阅读了相关内容但没有使用它。这是我未来的挑战之一。我害怕很多人中的一个。

Lee Mac 发表于 2022-7-6 15:15:30

 
说实话,弧度并不难——它只是一种不同的角度思考方式。如果你愿意的话,可以用度来表示,然后把度除以180,再乘以π。
 
 
您是不想使用“getreal”还是专门将其限制为整数?
 
 
对不起,我应该用更简单的语言-
 
因此=因此=因此=如此
 
我的意思是,当创建一个对象时,它被添加到数据库中,entlast将使用数据库中的最后一个实体,因此使用创建的最后一个实体。
 
 
 
是的,您可以在图形中“entmake”您的块,使其具有属性-但这需要更多的编码。

Lee Mac 发表于 2022-7-6 15:20:13

这应该可以帮助您:
 

(defun c:box1(/ *error* vlst ovar ss len leng dist pt1 pt2 pt3 pt4 pt5 pt6)

; Error Handler

(defun *error*(msg)
   (if ovar
   (mapcar 'setvar vlst ovar)) ; If old variables are stored, reset them.
   (if (not (member msg '("Function cancelled" "quit / exit abort")))
; If the msg isn't one in this list
   (princ (strcat "\n<!> Error: " msg " <!>"))) ; then print it.
   (princ))

(setq vlst '("CMDECHO" "OSMODE" "ORTHOMODE")
       ovar (mapcar 'getvar vlst)

       ss (ssadd); Create an Empty Selection Set

; Define Functions and Localise Variables

       len (getdist "\nLength1:")

       leng (getdist "\nLength2:")

; I'd be more inclined to use "getdist"
; so that the user can pick the distance.

       dist (getdist "\nDistance:")

       dia (getreal "\nDiameter: ")

       pt1 (getpoint "\nInsertion:")

       pt2 (polar pt1 0 dist)
      
;;;                  pt1 +-----+
;;;                           pt2

       pt3 (polar pt2 (/ pi 2) (* len 0.5))
      
;;;                           pt3
;;;                              +
;;;                              |
;;;                              |
;;;                  pt1 +-----+
;;;                           pt2

       pt4 (polar pt3 0 leng)

;;;                           pt3   pt4
;;;                              +-----+
;;;                              |
;;;                              |
;;;                  pt1 +-----+
;;;                           pt2

       pt5 (polar pt4 (* pi 1.5) len)
      
;;;                           pt3   pt4
;;;                              +-----+
;;;                              |   |
;;;                              |   |
;;;                  pt1 +-----+   |
;;;                           pt2    |
;;;                                    |
;;;                                    +
;;;                                 pt5

       pt6 (polar pt5 pi leng)

;;;                           pt3   pt4
;;;                              +-----+
;;;                              |   |
;;;                              |   |
;;;                  pt1 +-----+   |
;;;                           pt2    |
;;;                                    |
;;;                              +-----+
;;;                           pt6   pt5

       ) ; End Setq

(mapcar 'setvar vlst '(0 0 1)); Set the Variables to how we want them

(command "_.pline" pt3 pt4 pt5 pt6 "_C"); Make the Polyline

; Remember to use "_." prefix to make it
; compatible for all language versions.

(ssadd (entlast) ss); Add the polyline to the selection set

(command "_.circle" pt3 "_D" dia); Create the Circle

(ssadd (entlast) ss); Add the Circle to the selection set

(command "_.rotate" ss "" pt1 pause)

(mapcar 'setvar vlst ovar) ; Reset System Variables

(princ)

; Exit Cleanly

) ; End box1

alanjt 发表于 2022-7-6 15:22:20

李,我只是想让你知道,当使用命令绘制等时,你可以在例程中放置一个osnap覆盖,以消除运行osnap的问题。我知道你在这套动作中已经打好了基础;我只是想确保你意识到这一点。例如
(command "_.pline" "_non" pt3 "_non" pt4 "_non" pt5 "_non" pt6 "_non" "_C")
虽然有点冗长,但它消除了控制OSNAP的需要。

MarcoW 发表于 2022-7-6 15:25:11

@李:我试着去理解。有些我不知道,请看下面并纠正我的错误。
 

(defun c:box1(/ *error* vlst ovar ss len leng dist pt1 pt2 pt3 pt4 pt5 pt6)
; all systems go, got the message!

; Error Handler
; we would have to spend a chapter on the error handler for I don't get the code.

(defun *error*(msg)

; defun without the c: is a subfunction, correct?
; How is a subfuntion invoked? Or wil it work automatically whenever the main function is invoked?

   (if ovar

; If the old variables...

(mapcar 'setvar vlst ovar)); If old variables are stored, reset them.

; are stored (mapcar = stored ??) then set the variable vlst to ovar..
; as if ovar & vlst were variables... where is the "setq ovar / setq vlst" ??

(if (not (member msg '("Function cancelled" "quit / exit abort")))

; If the error message isn't one in this list ("member msg") then:

   (princ (strcat "\n<!> Error: " msg " <!>"))) ; then print it.
   (princ))

; Yes prinC it...

(setq vlst '("CMDECHO" "OSMODE" "ORTHOMODE")
ovar (mapcar 'getvar vlst)

; oops... here they are the vlst and ovar setq's...
; so this is the point where i think "first setq's then refer to them..
; this seems upside down...
; what is the'in there?

       ss (ssadd); Create an Empty Selection Set

; so ss is the variable and ssadd is a function to create a SelectionSet?
; an empty one, in wich certain entities can be added

; Define Functions and Localise Variables
       len (getdist "\nLength1:")
       leng (getdist "\nLength2:")
; I'd be more inclined to use "getdist"
; so that the user can pick the distance.

; okay, in some cases that might come in handy and since
; the keybord methode works too its maybe better to use getdist.

       dist (getdist "\nDistance:")
       dia (getreal "\nDiameter: ")

; the getreal function is in fact better for it can contain decimal values
; i used integer for i was thinking in round numbers (don't know english for that")
; you know what i mean

       pt1 (getpoint "\nInsertion:")
       pt2 (polar pt1 0 dist)

;;;                  pt1 +-----+
;;;                           pt2
       pt3 (polar pt2 (/ pi 2) (* len 0.5))

; Lee you altered the line above, I get it for (* pi 0.5) is the
; same as when typing (/ pi 2)
; Just wanted you to know I noticed :-)

;;;                           pt3
;;;                              +
;;;                              |
;;;                              |
;;;                  pt1 +-----+
;;;                           pt2
       pt4 (polar pt3 0 leng)
;;;                           pt3   pt4
;;;                              +-----+
;;;                              |
;;;                              |
;;;                  pt1 +-----+
;;;                           pt2
       pt5 (polar pt4 (* pi 1.5) len)

;;;                           pt3   pt4
;;;                              +-----+
;;;                              |   |
;;;                              |   |
;;;                  pt1 +-----+   |
;;;                           pt2    |
;;;                                    |
;;;                                    +
;;;                                 pt5
       pt6 (polar pt5 pi leng)
;;;                           pt3   pt4
;;;                              +-----+
;;;                              |   |
;;;                              |   |
;;;                  pt1 +-----+   |
;;;                           pt2    |
;;;                                    |
;;;                              +-----+
;;;                           pt6   pt5
       ) ; End Setq
(mapcar 'setvar vlst '(0 0 1)); Set the Variables to how we want them

; Problem: The mapcar thingy is not understood...
; I'd rather google a bit

(command "_.pline" pt3 pt4 pt5 pt6 "_C"); Make the Polyline
; Remember to use "_." prefix to make it
; compatible for all language versions.

; i put a sticky note on my forehead + mirror besides monitor.

(ssadd (entlast) ss); Add the polyline to the selection set

; Because (setq ss (ssadd)) has no further parameters it stayed empty at first
; Now (ssad (entlast) ss) means "put last created entity into the set ss".

(command "_.circle" pt3 "_D" dia); Create the Circle
(ssadd (entlast) ss); Add the Circle to the selection set
(command "_.rotate" ss "" pt1 pause)
(mapcar 'setvar vlst ovar) ; Reset System Variables

; Did I tell you i didn't get that one?

(princ)
; Exit Cleanly
) ; End box1

 
在我的案例中需要做的是,我首先尝试理解错误处理,这在我看来非常重要。
 
然后是地图车,因为我会用一种非常简单的方法,比如setvar oldosmode等等。
 
我喜欢这样做,我的意思是弄清楚写了什么。只有复制结束粘贴并不能为我提供知识型的问题。
 
感谢您的回复。

Lee Mac 发表于 2022-7-6 15:28:46

 
感谢您指出这一点-是的,我知道这一点,但我不喜欢使用这种方法,因为它似乎是一种“变通方法”,而且,当使用命令调用方法绘制多个对象时“(命令…”你必须记住每次都要加上“_non”-留有出错的余地。。。

Lee Mac 发表于 2022-7-6 15:33:01

至于你的另一个回复——我们可能整天都在这里。。。
 
没有多少人理解“mapcar”——这是一个非常有用的功能。我不确定我是否是向你解释这件事的最佳人选,但我会尽力的。
 
Mapcar将所提供的函数应用于所提供列表中的每个成员,并返回执行此操作的结果列表。
 
因此:
 

(mapcar 'setvar (list "CMDECHO" "OSMODE") (list 0 0))

 
与相同
 

(setvar "CMDECHO" 0)
(setvar "OSMODE" 0)

 
阅读mapcar上的Visual LISP编辑器(VLIDE)帮助文件以获得更多理解。
 
至于撇号,它只是意味着它后面的语句没有被求值,所以:
 

(setq lst '(1 2 3))

 
与以下内容相同:
 

(setq lst (list 1 2 3))

 
至于错误处理程序和子函数。。。。这完全是另一回事。。。关于AfraLISP,有很多关于LISP中错误处理的信息,我也写了一个常见问题解答(目前还没有,但应该很快就会有!)。
 
希望这有帮助!
 

MarcoW 发表于 2022-7-6 15:35:59

舒尔这很有帮助,但现在,让我们到此为止。
我有太多“担心”了…:-)
 
我知道,今天我会去参观。我很快就会回来。。。你怎么会认为我不会呢。
 
Tnx到目前为止的信息,我现在要挣扎一下。
页: 1 [2]
查看完整版本: 计算器有点问题