Home Drawing sample
Learn command, AutoLISP, Problem AutoCAD, การใช้งาน AutoCAD หลากหลายความรู้หลากหลายปัญหา ร่วมแก้ไขแบ่งปันปัญหาแห่ง CAD การรวมกันคิด สามารถทำให้ผ่านพ้นไปได้ และหาแนวทางแก้ปัญหาได้เกือบทุกปัญหา ลุงธี57
Begin with Command "BOX"
เป็นคำสั่งในชุดแรกๆเริ่มจากการเขียนตามหนังสือ
แล้วมาต่อยอดภายหลังครับ
(defun getinfo ()
(setq pt1 (getpoint "pick first corner:"))
(setq pt3 (getcorner pt1 "pick opposite corner:"))
)
(defun procinfo ()
(setq pt2 (list (car pt3) (cadr pt1)))
(setq pt4 (list (car pt1) (cadr pt3)))
)
(defun output()
(command "pline" pt1 pt2 pt3 pt4 "c")
)
(defun C:BOX1 (/ pt1 pt2 pt3 pt4)
(getinfo)
(procinfo)
(output)
)
(defun C:3DBOX (/ pt1 pt2 pt3 pt4 h)
(getinfo)
(setq h (getreal "Enter height of box: "))
(procinfo)
(output)
(command "change" "L" "" "P" "thickness" h ""
"3dface" pt1 pt2 pt3 pt4 ""
"3dface" ".xy" pt1 h ".xy" pt2 h
".xy" pt3 h ".xy" pt4 h ""
)
)
(defun C:3DWEDGE (/ pt1 pt2 pt3 pt4 h)
(getinfo)
(setq h (getreal "Enter height of wedge: "))
(procinfo)
(output)
(command "3dface" pt1 pt4 ".xy" pt4 h ".xy" pt1 h pt2 pt3 ""
"3dface" pt1 pt2 ".xy" pt1 h pt1 ""
"copy" "L" "" pt1 pt4
)
)
แล้วมาต่อยอดภายหลังครับ
(defun getinfo ()
(setq pt1 (getpoint "pick first corner:"))
(setq pt3 (getcorner pt1 "pick opposite corner:"))
)
(defun procinfo ()
(setq pt2 (list (car pt3) (cadr pt1)))
(setq pt4 (list (car pt1) (cadr pt3)))
)
(defun output()
(command "pline" pt1 pt2 pt3 pt4 "c")
)
(defun C:BOX1 (/ pt1 pt2 pt3 pt4)
(getinfo)
(procinfo)
(output)
)
(defun C:3DBOX (/ pt1 pt2 pt3 pt4 h)
(getinfo)
(setq h (getreal "Enter height of box: "))
(procinfo)
(output)
(command "change" "L" "" "P" "thickness" h ""
"3dface" pt1 pt2 pt3 pt4 ""
"3dface" ".xy" pt1 h ".xy" pt2 h
".xy" pt3 h ".xy" pt4 h ""
)
)
(defun C:3DWEDGE (/ pt1 pt2 pt3 pt4 h)
(getinfo)
(setq h (getreal "Enter height of wedge: "))
(procinfo)
(output)
(command "3dface" pt1 pt4 ".xy" pt4 h ".xy" pt1 h pt2 pt3 ""
"3dface" pt1 pt2 ".xy" pt1 h pt1 ""
"copy" "L" "" pt1 pt4
)
)
คำสั่งเสริม AutoLISP ช่วยเขียนลูกศร
คำสั่งเสริม AutoLISP ช่วยเขียนลูกศร
(defun C:ARROW ()
(setvar "osmode" 0)(setq oldcolor (getvar "cecolor"))
(setq AR1 (getpoint "\nClick on Start point of arrow line: ")
AR2 (getpoint ar1 "\nClick on Next point of arrow line: ")
AR3 (getpoint ar2 "\nClick on Next point of arrow line: ")
)
(setq ang (angle ar1 ar2) angl (+ ang (/ pi 2.)) angr (+ ang (* 3 (/ pi 2.)))
r (polar ar1 angr 0.15) l (polar ar1 angl 0.15) ur (polar r ang 0.26)
ul (polar l ang 0.26)
)
(command "color" "5" "pline" ar1 "w" "0" "" ur ul ar1 ar2 ar3 "")
(command "color" oldcolor)
)
(defun C:ARROW-R ()
(setvar "osmode" 0)(setq oldcolor (getvar "cecolor"))
(setq AR1 (getpoint "\nClick on Start point of arrow line: ")
AR2 (getpoint ar1 "\nClick on End point of arrow line: ")
)
(setq ang (angle ar2 ar1) angl (+ ang (/ pi 2.)) angr (+ ang (* 3 (/ pi 2.)))
r (polar ar2 angr 0.15) l (polar ar2 angl 0.15) ur (polar r ang 0.26)
ul (polar l ang 0.26)
)
(command "color" "5" "pline" ar1 "w" "0" "" ar2 ur ul ar2 "")
(command "color" oldcolor)
)
(defun C:ARROW ()
(setvar "osmode" 0)(setq oldcolor (getvar "cecolor"))
(setq AR1 (getpoint "\nClick on Start point of arrow line: ")
AR2 (getpoint ar1 "\nClick on Next point of arrow line: ")
AR3 (getpoint ar2 "\nClick on Next point of arrow line: ")
)
(setq ang (angle ar1 ar2) angl (+ ang (/ pi 2.)) angr (+ ang (* 3 (/ pi 2.)))
r (polar ar1 angr 0.15) l (polar ar1 angl 0.15) ur (polar r ang 0.26)
ul (polar l ang 0.26)
)
(command "color" "5" "pline" ar1 "w" "0" "" ur ul ar1 ar2 ar3 "")
(command "color" oldcolor)
)
(defun C:ARROW-R ()
(setvar "osmode" 0)(setq oldcolor (getvar "cecolor"))
(setq AR1 (getpoint "\nClick on Start point of arrow line: ")
AR2 (getpoint ar1 "\nClick on End point of arrow line: ")
)
(setq ang (angle ar2 ar1) angl (+ ang (/ pi 2.)) angr (+ ang (* 3 (/ pi 2.)))
r (polar ar2 angr 0.15) l (polar ar2 angl 0.15) ur (polar r ang 0.26)
ul (polar l ang 0.26)
)
(command "color" "5" "pline" ar1 "w" "0" "" ar2 ur ul ar2 "")
(command "color" oldcolor)
)