교차점 찾기
;;교차점 찾기
(defun wall_intersectwith ( s1 s2 key / obj1 obj2)
;(princ s1)(princ s2)
(setq obj1 (vlax-ename->vla-object s1)
obj2 (vlax-ename->vla-object s2)
newPt (vlax-invoke obj1 'intersectwith obj2 key) );;벽시작에 트림 및 연장
newPt
)
;--------------------------------------------------------------------------------
;;1101 ;;s1객체의 p1 p2로 이동하기 (교차점이 있는것 확인하기 어려워 그냥 2개다 이동:결론 1개점 이동됨)
(defun ent_move_point (s1 p1 p2 / pt1 pt2 obj1)
;;객체각도를 통일해서 선방향지정
(if (> (angle p1 p2) (angle p2 p1)) (setq pt1 p2 pt2 p1 )(setq pt1 p1 pt2 p2 ))
(setq obj1 (vlax-ename->vla-object s1))
(vlax-put-property obj1 'StartPoint (vlax-3d-Point pt1))
(vlax-put-property obj1 'EndPoint (vlax-3d-Point pt2))
)
;--------------------------------------------------------------------------------
;;s1객체의 p1-npt1 이동 p2-npt2 신규
(defun ent_move_point2 ( s1 p1 p2 npt1 npt2 / pt1 pt2 obj1 la)
;(princ "\n ent_move_point2 ")(princ p1)(princ p2 )(princ pt1) (princ npt2) (princ la)
(setq la (cdr (assoc 8 (entget s1))))
(if ( < (distance p1 npt1 )(distance p1 npt2 ))
(progn (ent_move_point s1 p1 npt1 )(entmakeLine2e npt2 p2 la) (ent_move_point (entlast) npt2 p2) (ent_change_500 (entlast) s1 ) )
(progn (ent_move_point s1 p1 npt2 )(entmakeLine2e npt1 p2 la) (ent_move_point (entlast) npt1 p2) (ent_change_500 (entlast) s1 ) )
)
;(entlast)
)
;--------------------------------------------------------------------------------
;-신규선 기존선이랑 동일하게 변경 (복사 원본)
(defun ent_change_500 ( s2 s1 )
(setq vlaTempObject (vlax-ename->vla-object s2) vlaObject (vlax-ename->vla-object s1))
(vla-put-Layer vlaTempObject (vla-get-Layer vlaObject))
(vla-put-Linetype vlaTempObject (vla-get-Linetype vlaObject))
(vla-put-Color vlaTempObject (vla-get-Color vlaObject))
(vla-put-LinetypeScale vlaTempObject (vla-get-LinetypeScale vlaObject))
)
;--------------------------------------------------------------------------------
;;p1과 npt1,2중 가까운벽에 그리기
(defun ent_move_point3 (s1 p1 npt1 npt2 / pt1 pt2 obj1 la)
;(princ "\n ent_move_point3 ")(princ p1)(princ p2 )(princ pt1) (princ npt2)
(if ( < (distance p1 npt1 )(distance p1 npt2 ))
(progn (ent_move_point s1 p1 npt1 ))
(progn (ent_move_point s1 p1 npt2 ))
)
)
;--------------------------------------------------------------------------------
;;p1 p2 중 무조건 npt1,2중 가까운벽에 그리기
(defun ent_move_point4 (s1 p1 p2 npt1 npt2 / p3 npt3 pt1 pt2 obj1 la)
;(princ "\n ent_move_point4 ")(princ p1)(princ p2 )(princ npt2)
(setq npt3 (midpoint npt1 npt2))
(if ( < (distance p1 npt3 )(distance p2 npt3 )) (setq p3 p2)(setq p3 p1) )
(if ( < (distance p3 npt1 )(distance p3 npt2 ))
(progn (ent_move_point s1 p3 npt1 ))
(progn (ent_move_point s1 p3 npt2 ))
)
)
;--------------------------------------------------------------------------------
;;s1측 트림
(defun wall_wct_trim ( s1 s2 mpt)
(setq obj1 (vlax-ename->vla-object s1)
obj2 (vlax-ename->vla-object s2)
)
(wall_wct_trim_OBJ obj1 obj2 mpt)
)
;-----------------------------------------------------------
(defun wall_wct_trim_OBJ ( obj1 obj2 mpt)
(setq pt1 (vlax-safearray->list (vlax-variant-value (vlax-get-property obj1 'StartPoint)))
pt2 (vlax-safearray->list (vlax-variant-value (vlax-get-property obj1 'EndPoint)))
newPt (vlax-invoke obj1 'intersectwith obj2 3)
)
(obj_inter_move_point obj1 newPt mpt pt1 pt2)
)
;--포인트 이동---------------------------------------------------------
;;mpt에서 가까운 점을 nnewPt 이동
(defun obj_inter_move_point ( obj1 newPt mpt pt1 pt2)
(if (< (distance pt1 mpt )(distance pt2 mpt))
(vlax-put-property obj1 'StartPoint (vlax-3d-Point newPt))
(vlax-put-property obj1 'EndPoint (vlax-3d-Point newPt))
)
)
;;-------------------------------------------------------------------------;;
;;벽만 추출하기
(defun WCT_wall_ent ( ss1 cno_lst1 / n Nset1 en)
(setq n 0 Nset1 (ssadd) )
(repeat (length cno_lst1)
(setq en (ssname ss1 (nth n cno_lst1)) n (+ n 1) Nset1 (ssadd en Nset1))
)
Nset1
)
;-----------------------------------------------------------
;;3선의 교차점에 선그리기
(defun wall_wct_line2 (s11 s12 s2)
(setq obj11 (vlax-ename->vla-object s11)
obj12 (vlax-ename->vla-object s12)
obj2 (vlax-ename->vla-object s2)
la1 (vla-get-layer obj11)
pt1 (vlax-invoke obj11 'intersectwith obj2 3)
pt2 (vlax-invoke obj12 'intersectwith obj2 3)
)
(entmakeLine2e pt1 pt2 la1)
)
;-----------------------------------------------------------
'Auto CAD > lisp' 카테고리의 다른 글
vl-directory-files (파일 이나 폴더이름 가져오기) (0) | 2018.12.02 |
---|---|
vlisp-compile (AutoLISP/Visual LISP IDE) (0) | 2018.12.01 |
vlr-lisp-reactor (리액터) (0) | 2018.11.30 |
Vlax-Curve (0) | 2018.11.30 |
VLR, VLA, VLAX (0) | 2018.11.28 |