안녕하세요~
LIsp 관련해서 문의 드릴 사항이 있어 이렇게 글을 남기네요~
다름이 아니라 기존에 CAD를 이용하면서 사용하던 LISP이 있는데
이번에 회사 내부에서 문제가 있어 CAD LT와 서드파티 제품인 CADMAS로 사용하게 되었습니다.
그런데 기존 CAD에서 사용하던 LISP이 몇개는 사용이 되는데 대부분 사용이 안되네요……
뭐가 문제인지도 잘 모르겠고…
몇일째 고민을 해봐도 이유를 모르겠네요…. 고수님들 답변 좀 부탁 드리겠습니다.
——————————————————————————————————————————–
(defun S::STARTUP()
(SETVAR “CMDECHO” 0)
(setvar “modemacro” “$(if,$(getvar,orthomode),)$(getvar,dwgname)-$(getvar,dimscale)-$(getvar,dimlfac)-$(/,$(getvar,viewsize),286)”)
; “undefine” “leader”
; “undefine” “PSPACE”)
)
(defun c:0()(setq p1 (ssget))(command “chprop” p1 “” “LA” “0” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:1()(setq p1 (ssget))(command “chprop” p1 “” “LA” “01” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:2()(setq p1 (ssget))(command “chprop” p1 “” “LA” “02” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:3()(setq p1 (ssget))(command “chprop” p1 “” “LA” “03” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:4()(setq p1 (ssget))(command “chprop” p1 “” “LA” “04” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:5()(setq p1 (ssget))(command “chprop” p1 “” “LA” “05” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:6()(setq p1 (ssget))(command “chprop” p1 “” “LA” “06” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:7()(setq p1 (ssget))(command “chprop” p1 “” “LA” “07” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:8()(setq p1 (ssget))(command “chprop” p1 “” “LA” “08” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:9()(setq p1 (ssget))(command “chprop” p1 “” “LA” “09” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:11()(setq p1 (ssget))(command “chprop” p1 “” “LA” “11” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
(defun c:12()(setq p1 (ssget))(command “chprop” p1 “” “LA” “12” “C” “BYLAYER” “LT” “BYLAYER” “”)(princ));
;tap autolisp program
;
(defun C:tap_circle( / c d l)
(initget 1)
(setq old_lt (getvar “celtype”) old_c (getvar “cecolor”) old_om (getvar “osmode”) c (getpoint “ncenter point: “))
(initget 7)
(setq d (/ (getdist c “Daimeter of tap: “) 2) l (+ d 2.5))
(setvar “osmode” 0)
(command “color” “bylayer” “”
“.circle” c (* d 0.8)
“color” “3” “”
“arc” (polar c (* pi 1.4) d) “e” (polar c (* pi 1.1) d) c
“color” 1 “linetype” “set” center “”
“line” (polar c pi l)
(polar c 0 l) ^c
“line” (polar c (/ pi 2) l)
(polar c (* pi 1.5) l) ^c
“color” old_c “linetype” “set” old_lt “”)
(setvar “osmode” old_om)
(prin1)
)
;Circle and Arc center line–autolisp program
;
(defun C:center_line( / c s a st cc ccl len dims)
(setq old_lt (getvar “celtype”) old_c (getvar “cecolor”) c 0 s (ssget) old_om (getvar “osmode”))
(setq dims (getvar “dimscale”))
(setvar “osmode” 0)
(if (= s nil) (prompt “nnot selected circle or arc”)
(repeat (sslength s)
(setq a (entget (setq aa(ssname s c))) c (1+ c))
(if (or (= “CIRCLE” (cdr(assoc 0 a))) (= “ARC” (cdr(assoc 0 a))))
(progn
(setq st (cdr(assoc 10 a)) len (+ (cdr (assoc 40 a)) 3.0) ccl(ssget “C” st st) cc 0)
(if (/= ccl nil)
(progn
(terpri)(princ (sslength ccl))
(redraw (cdr(assoc -1 a)) 3)
(initget “Yes No”)
(if (= “No” (getkword ” Clear old center line? <Yes> or No: “))
‘()
(repeat (sslength ccl)
(if (= “LINE” (cdr (assoc 0 (entget (ssname ccl cc)))))
(entdel (ssname ccl cc)))
(setq cc (1+ cc))
)
)
(redraw (cdr(assoc -1 a)) 4)
)
)
(command “color” “1” “” “linetype” “set” “center” “”)
(command “line” (polar st pi len)
(polar st 0 len)
“”
“line” (polar st (/ pi 2) len)
(polar st (* pi 1.5) len)
“”)
)
)
)
)
(command “color” old_c “” “linetype” “set” old_lt “”)
(setvar “osmode” old_om)
(prin1)
)
;long hole
(defun C:slot( / an bp wi wit a p1 p2 p3 p4)
(setq old_om (getvar “osmode”))
(setq an(getpoint (setq bp (getpoint “Base point “)) “Length “)
wi (/ (getreal “Width “) 2) wit (+ wi 2.5)
a(angle bp an)
p1 (polar bp (+ a (/ pi 2)) wi)
p2 (polar bp (+ a (* pi 1.5)) wi)
p3 (polar an (+ a (/ pi 2)) wi)
p4 (polar an (+ a (* pi 1.5)) wi)
old_c (getvar “cecolor”) old_lt (getvar “celtype”))
(setvar “osmode” 0)
(command “line” p1 p3
“”
“line” p2 p4
“”
“arc” p1 “c” bp p2
“arc” p4 “c” an p3
“color” old_c “linetype” “set” old_lt “”)
(setvar “osmode” old_om)
(prin1)
)
;doul line
(defun C:bond ( / loop a b x x1 x2 y1 y2 g1 g2 g3 g4 g5 g6)
(setq loop 1)
(while loop
(while (not(setq a (car(entsel “nSelect first object “))))
)
(if (= “LINE” (cdr(assoc 0 (entget a))))
(setq loop nil)
(prompt (strcat “nBad type ” (cdr(assoc 0 (entget a)))))
)
)
(redraw a 3)
(setq loop 1 a (entget a))
(while loop
(while (not(setq b (car(entsel “nSelect second object “))))
)
(if (= “LINE” (cdr(assoc 0 (entget b))))
(setq y1 (cdr(assoc 10 (entget b))) y2 (cdr(assoc 11 (entget b)))
loop nil)
(prompt (strcat “nBad type ” (cdr(assoc 0 (entget b)))))
)
)
(entdel b)
(setq x1 (cdr(assoc 10 a)) x2 (cdr(assoc 11 a))
g1 (distance x1 x2) g2 (distance x1 y1) g3 (distance x1 y2)
g4 (distance x2 y1) g5 (distance x2 y2) g6 (distance y1 y2)
x (max g1 g2 g3 g4 g5 g6))
(cond
( (= x g1) (setq y1 x1 y2 x2))
( (= x g2) (setq y2 x1))
( (= x g3) (setq y1 x1))
( (= x g4) (setq y2 x2))
( (= x g5) (setq y1 x2))
)
(entmod (subst (cons 10 y1) (cons 10 x1) (subst (cons 11 y2) (cons 11 x2) a)))
(prin1)
)
(defun noele(dev num / olddata newdata data data1)
(setq data (cdr (assoc num dev)))
(setq olddata (assoc num dev))
(setq data1 (list (car data) (cadr data) 0))
(setq newdata (cons num data1))
(setq dev (subst newdata olddata dev))
)
(defun chtime(data / rtcode)
(setq rtcode (strcat (rtos (/ data 3600.) 2 0) “:”))
(setq data (- data (* (fix (/ data 3600)) 3600.)))
(setq rtcode (strcat rtcode (rtos (/ data 60.) 2 0) “:”))
(setq data (- data (* (fix (/ data 60)) 60.)))
(setq rtcode (strcat rtcode (rtos data 2 0)))
)
;|*********************Dim Text Change**********************************|;
(defun 3d2d_main( /
dcl_id3 selobj selnum idnum ed obj name starttime endtime
)
(setq oldcmd (getvar “cmdecho”))
(setvar “cmdecho” 0)
(princ “n>>Select Object<<“)
(setq selobj (ssget))
(setq selnum (sslength selobj))
(setq starttime (getvar “DATE”))
(setq starttime (fix (* (- starttime (fix starttime)) 100000.)))
(setq idnum 0.)
(repeat selnum
(setq ename (ssname selobj idnum))
(setq ed (entget ename))
(if (= (cdr (assoc 0 ed)) “POLYLINE”)
(progn ;THEN
(setq nxt ename) ;첫 엔티티 이름
(while (setq nxt (entnext nxt))
(setq ent (entget nxt)) ;엔티티정보축출
(if (= (cdr (assoc 0 ent)) “VERTEX”) ;절점일때만
(progn
(setq oldpnt (cdr (assoc 10 ent)))
(setq ent (subst (cons 10 (list (car oldpnt) (cadr oldpnt) 0))
(assoc 10 ent) ent))
(entmod ent)
(entupd nxt)
);progn
);if
);while
);progn
(progn ;ELSE
(setq o38 (assoc 38 ed))
(setq n38 (cons (car o38) 0.0))
(setq ed (subst n38 o38 ed))
(setq obj (cdr (assoc 0 ed)))
(setq name (cdr (assoc 1 ed)))
(setq ed (noele ed 10))
(setq ed (noele ed 11))
(setq ed (noele ed 13))
(setq ed (noele ed 14))
(setq ed (noele ed 21))
(setq ed (noele ed 30))
(setq ed (noele ed 31))
(entmod ed)
);progn
);if
(setq idnum (1+ idnum))
(princ (strcat “Converting Data Num : ” (rtos idnum 2 0) “(” (rtos (* (/ idnum selnum) 100) 2 0) “%)” (chr 13)))
);repeat
(setvar “ELEVATION” 0)
(setq endtime (getvar “DATE”))
(setq endtime (fix (* (- endtime (fix endtime)) 100000.)))
(princ (strcat “nElapsed Time : ” (chtime (- endtime starttime)) “nConverting End…..”))
(setq *error* OLDERROR)
(setvar “cmdecho” OLDCMD)
(princ)
);defun
;|**********************************************************************|;
(defun C:ZZ() (3d2d_main))
(princ “nLoading Complete…… Programed by Shin Jong-Hwa by DooSan ENG.nType : 3d2d”)
(princ)