绘制楼梯
大家好,我试图写一个函数来绘制楼梯的基本轮廓。
有一两次它对我非常有效。但在那之后,它只是画了一些垃圾。有人能看看下面的代码并提出一些建议吗?
(defun c:Stp()
(setq Point (getpoint "\nPick a Point:"))
(setq Rise (getdist "\nEnter rise of each step:"))
(setq Tread (getdist "\nEnter tread of each step:"))
(setq Nos (getint "\nEnter number of steps:"))
(setq LandingAt (Getint "Number of steps in first flight:"))
(setq P1 (list (car Point) (cadr Point)))
(setq LandingLength (getdist "\nEnter Length of Landing:"))
(setq n 0)
(While (< n Nos)
(if
(<= n LandingAt)
(Progn ;If True
(Setq
P2 (polar Point (GetRad 90) Rise)
P3 (Polar P2 0 Tread)
)
)
(progn ;Else
(Setq
P2 (polar Point (GetRad 90) Rise)
P3 (Polar P2 (GetRad 180) Tread)
)
)
)
(command "LINE" Point P2 P3 "")
(Setq Point P3)
(setq n (1+ n))
);While Ends
);STP Ends
;======================================::::::
;Function to Convert Degrees to Radians::::::
;======================================::::::
(defun GetRad(Ang)
(/ (* 3.14 Ang) 180)
)
应该是这样的。
(defun c:Stp()
(defun c:Stp ()
应该是
(defun GetRad(Ang)
除此之外,请将您的论点本地化。
这是很好的练习,伙计。
当做
塔瓦特 当然我会。。。
这是我从零开始认真学习Autolisp的第四天。。。
因此,我在这里得到的任何建议都将非常有价值。。!!!
谢谢。。。 只是有这样的冲动:
(defun GetRad (Ang)
做起来很有趣,我只是一个学习者;-) 这将避免与捕捉点混淆。
(defun c:Stp (/ Point Rise Tread Nos LandingAt P1 LandingLength n P2 P3 OsmodeOld)
(setq Point (getpoint "\nPick a Point:")
Rise (getdist "\nEnter rise of each step:")
Tread (getdist "\nEnter tread of each step:")
Nos (getint "\nEnter number of steps:")
LandingAt (Getint "\nNumber of steps in first flight:")
P1 (list (car Point) (cadr Point))
LandingLength (getdist "\nEnter Length of Landing:")
n 0
OsmodeOld (getvar "OSMODE")
) ;_setq
(setvar "OSMODE" 0)
(While
(< n Nos)
(if
(<= n LandingAt)
(Progn ;If True
(Setq
P2 (polar Point (GetRad 90) Rise)
P3 (Polar P2 0 Tread)
) ;_setq
) ;_progn
(progn ;Else
(Setq
P2 (polar Point (GetRad 90) Rise)
P3 (Polar P2 (GetRad 180) Tread)
) ;_setq
) ;_progn
)
(vl-cmdf "_.LINE" Point P2 P3 "")
(Setq Point P3
n (1+ n)
) ;_setq
) ;While Ends
(setvar "OSMODE" OsmodeOld)
(princ)
) ;STP Ends
;======================================::::::
;Function to Convert Degrees to Radians::::::
;======================================::::::
(defun GetRad (Ang)
(/ (* 3.14 Ang) 180)
)
;|«Visual LISP© Format Options»
(120 2 2 2 nil "Ende von " 100 9 0 0 0 T T nil T)
;*** DO NOT add text below the comment! ***|;
塔瓦特 Still OSMODE was not set when I did it. I set it to '0' at the beginning and it it worked.
Thankyou MacroW for the revised code...!! You are right, too much hurrie is no good, code above is updated. Thankyou...!!! Thankyou All,
I modified my code, atlast, like this;
(defun c:Stp (/ Point Rise Tread Nos LandingAt P1 LandingLength n P2 P3 OSM) (setq Point (getpoint "\nPick a Point:")) (Setq OSM (getvar "OSMODE")) (setvar "OSMODE" 0) (setq Rise (getdist "\nEnter rise of each step:") Tread (getdist "\nEnter tread of each step:") Nos (getint "\nEnter number of steps:") LandingAt (Getint "Number of steps in first flight:") LandingLength (getdist "\nEnter length of the landing:") P1 (list (car Point) (cadr Point)) n 0 ) ;_setq(setq LandingDrawn 0)(While (< n Nos) (if ( Good to hear .
Best regards .
Tharwat
页:
[1]
2