Lee Mac 发表于 2022-7-6 09:20:40

这就决定了一切。非常感谢李。。。

ketongin 发表于 2022-7-6 09:22:20

我刚刚才意识到geomcal并没有预先加载到绘图会话中,
 
(defun c:test ( / _line pt1 pt2 pt1a pt1b ang )

   (defun _line ( a b ) (entmakex (list (cons 0 "LINE") (cons 10 a) (cons 11 b))))
   
   (if
       (and
         (setq pt1 (getpoint "\nPt1: "))
         (setq pt2 (getpoint "\nPt2: " pt1))
       )
       (progn
         ;; 'getpoint' returns points in UCS
         ;; pt1 = UCS
         ;; pt2 = UCS

         ;; 'angle' returns the angle measured from
         ;; the X-Axis of the current construction plane.

         (setq ang (angle pt1 pt2))

         ;; Now to calculate the points using the polar function:

         (setq pt1a
               (polar
                   (polar pt1 (- ang (/ pi 2.)) 6.0)
                   ang
                   10.0
               )
         )
         (setq pt1b
               (polar
                   (polar pt1 (+ ang (/ pi 2.)) 6.0)
                   ang
                   10.0
               )
         )

         ;; Lines are defined in WCS, so now we transform all points
         ;; from UCS to WCS:

         (setq pt1(trans pt11 0)
               pt1a (trans pt1a 1 0)
               pt1b (trans pt1b 1 0)
         )

         ;; Display the result:

         (_line pt1 pt1a)
         (_line pt1 pt1b)
       )
   )
   (princ)
)

Lee Mac 发表于 2022-7-6 09:27:19

谢谢pBe。我还将在我的子例程中包括这一点。没有你们我怎么活。非常感谢你!
 

ketongin 发表于 2022-7-6 09:29:48

Lee Mac 发表于 2022-7-6 09:33:23

 
Thanks, I'm glad it was comprehensible.
 
 
You can use it if you wish.
 
 
No, since getpoint returns points in UCS, not WCS.
 
If you needed the point in WCS, you would use:
 

(trans (getpoint "\nPoint: ") 1 0)

ketongin 发表于 2022-7-6 09:37:28

That sets it all. Much thanks Lee...

pBe 发表于 2022-7-6 09:39:32

I only realize just now that geomcal is not pre-loaded on a drawing session,
 

(defun c:test (/ p1 p2 p3 p1_ p2_) (if (not (member "geomcal.arx" (arx)))   (arxload "geomcal") )(setq p1 (getpoint "\nPick Point1")p2 (getpoint "\nPick Point2")p3 (getpoint "\nPick Point3") ) (setq p1_ (polar p1 (angle p1 p2) (/ (distance p1 p2) 2))p2_ (car (vl-sort (list p1 p2)    (function (lambda (y1 y2)         (> (cadr y1) (cadr y2))       )    ))    ) ) (if (

alanjt 发表于 2022-7-6 09:40:55

You can also use the area of a triangle...
 

(defun AT:TriangleArea (a b c) ;; Returns area of three provided points ;; If returned value is negative, last point (c) exists on right side of a-b vector ;; Alan J. Thompson, 06.09.10 (/ (- (* (- (car b) (car a)) (- (cadr c) (cadr a)))       (* (- (cadr b) (cadr a)) (- (car c) (car a)))    )    2. ))

ketongin 发表于 2022-7-6 09:45:26

Thanks pBe. I'll also include this on my artillery of sub routines. How can I live without you guys. Thank you very much!
 
页: 1 [2]
查看完整版本: 条件语句