Sidney2002 发表于 2003-1-21 12:02:00

谁帮我写一个AUTOlisp程序

本人因为工作关系经常要计算一个值很是浪费时间,谁帮我写一个谢谢!!

陈伯雄 发表于 2003-1-21 12:47:00

好吧...

(Defun C:LL ()
       (SetQ l1 (GetDist "\nL1=")
             l2 (GetDist "\nL2=")
             w1 (GetDist "\nW1=")
             w2 (GetDist "\nW2=")
              s (+ (/ l1 w1)(/ l2 w2))
       )
       (SetQ p0 (GetPoint "\nBase point: "))
       (Command "pline" p0
                        (Polar (GetVar "Lastpoint") 0 l2)
                        (Polar (GetVar "Lastpoint") (* 0.5 Pi) w2)
                        (Polar (GetVar "Lastpoint") (- Pi)(+ l2 w1))
                        (Polar (GetVar "Lastpoint") (- (* 0.5 Pi))(+ l1 w2))
                        (Polar (GetVar "LastPoint") 0 w1)
               "cl"
       )
       (Command "extrude" (EntLast) "" s "")
       (PrinC)
)

Sidney2002 发表于 2003-1-21 14:14:00

还是谢谢你,我的意思是....

首先谢谢你的热心帮助!!

我的意思不是用这个程序去画图,而是用这个程序

去算这个S值,即加载这个程序后,然后选择要计算

的图案,最后自动算出S

wljylsf 发表于 2008-10-28 14:00:00

wer

wljylsf 发表于 2008-10-28 14:39:00

(defun c:ll ()

graphscr
(setq p1 (getpoint "\n选取第一点")

  p2 (getpoint "\n选取第二点")

      p3 (getpoint "\n选取第三点")

      p4 (getpoint "\n选取第四点")

      p5 (getpoint "\n选取第五点")

   (setq dx1 (- car(p3) car(p2))

            dy1 (- cadr(p3) cadr(p2))

            dx2 (- car(p2) car(p1))

            dy2 (- cadr(p2) cadr(p1))

            dx3 (- car(p4) car(p3))

            dy3 (- cadr(p4) cadr(p3))

            dx4 (- car(p5) car(p4))

            dy4 (- cadr(p5) cadr(p4))

            l1 (getdist (sqrt (+ dx1*dx1 dy1*dy1)))

            w1 (getdist (sqrt (+ dx2*dx2 dy2*dy2)))

            l2 (getdist (sqrt (+ dx3*dx3 dy3*dy3)))

            w2 (getdist (sqrt (+ dx4*dx4 dy4*dy4)))

      )

   Dist (- (/ l1 w1) (/ l2 w2))

   (princ "\n距离为:")

   (princ dist)

   (princ)

)

wljylsf 发表于 2008-10-28 14:43:00

改为 Dist (+ (/ l1 w1) (/ l2 w2))

AMTONNY 发表于 2008-10-29 22:51:00

看看这个,如果是PLINE线变要炸开才可以用
页: [1]
查看完整版本: 谁帮我写一个AUTOlisp程序