프로그램
캐드 분류

(command "~~~")로 만든 객체 선택 리습 질문 있습니다.

컨텐츠 정보

  • 69 조회
  • 4 댓글
  • 0 추천
  • 0 비추천
  • 목록

본문

특정 선으로부터 일정 거리를 떨어진 지점에 선을 만들고 이 선까지 연장 혹은 트림 하는 리습을 제작 중입니다.  

지금 상태에서는 (command "offset" )을 통해 만들어진 객체를 한번 더 클릭해줘야 하는 불편함이 있습니다.
(원래는 xline을 사용하고 싶었으나 기준선이 pline인 경우 작동을 안해 offset을 사용하고 있습니다.)
이 객체를 따로 선택 안하고 (ssget) 등의 구문을 이용해 바로 사용하고 싶습니다.
방법 아시는 분 계시면 알려주세요 ????
아래는 해당 리습이고 인터넷에서 얻은 리습과 결합해 만들고 있습니다. 
;————————————————————————-
(defun c:e2 (/ a ds p1 p2 )
(vl-load-com)
(setvar "CMDECHO" 0)
(command "undo" "begin")
(setq a (car (entsel "nBase Line: ")))
(initget 128)
(setq p2 (getpoint "nDistance : "))
(cond 
((= (type p2) 'LIST)
(setq p1 (vlax-curve-getClosestPointTo a p2))
(setq ds(distance p1 p2))
(command "offset" ds a p2 "")
(princ ds)
)
((= (type p2) 'STR)
(setq ds(atof p2))
(command "offset" ds a "\" "")
)
(t)
)
(e3)
(command "undo" "end")
(princ)
)
;;; Touch.LSP                                              *
;;; Small routine to align endpoints of lines to an edge.  *
;;; The edge have to be a line.                            *
;;; The routine works by calculating the point of inter-   *
;;; section and change the nearest endpoint to that point  *
;;; 2001 Stig Madsen, no rights reserved                   *
;;; modified by qjchen, the edge line can be line or polyline *
;
;GREAT for PROJECTING LINES FOR ELEVATIONS !!!!!!!!!!!
;
(defun e3 (/ cmd ent entl spt ept sset a lent lentl lspt lept lint)
  (vl-load-com)
  (while (not ent)
    (setq ent (car (entsel "nSelect edge line: ")))
    (if ent
      (progn
(setq entl (entget ent))
      )
    )
  )
  (if ent
    (progn
      (redraw ent 3)
      (prompt "nSelect lines to touch edge: ")
      (setq sset (ssget '((0 . "LINE")))
    a 0
      )
      (if sset
(repeat (sslength sset)
  (setq lentl (entget (setq lent (ssname sset a)))
lspt (cdr (assoc 10 lentl))
lept (cdr (assoc 11 lentl))
  )
  (setq entttt (ssname sset a))
  (setq lint (nth 0 (x_intlst ent entttt acExtendOtherEntity)))
  (if lint
    (progn
      (if (< (distance lint lspt) (distance lint lept))
(entmod (subst
  (cons 10 lint)
  (assoc 10 lentl)
  lentl
)
)
(entmod (subst
  (cons 11 lint)
  (assoc 11 lentl)
  lentl
)
)
      )
    )
  )
  (setq a (1+ a))
)
(princ "nNo objects found")
      )
      (redraw ent 4)
    )
    (princ "nNo edge selected")
  )
  (princ)
)
;;; by kuangdao at xdcad
(defun x_intlst (obj1 obj2 param / intlst1 intlst2 ptlst)
  (if (= 'ENAME (type obj1))
    (setq obj1 (vlax-ename->vla-object obj1))
  )
  (if (= 'ENAME (type obj2))
    (setq obj2 (vlax-ename->vla-object obj2))
  )
  (setq intlst1 (vlax-variant-value (vla-intersectwith obj1 obj2 param)))
  (if (< 0 (vlax-safearray-get-u-bound intlst1 1))
    (progn
      (setq intlst2 (vlax-safearray->list intlst1))
      (while (> (length intlst2) 0)
(setq ptlst (cons (list (car intlst2) (cadr intlst2) (caddr intlst2))
  ptlst
    )
      intlst2 (cdddr intlst2)
)
      )
    )
  )
  ptlst
)
;————————————————————————-

관련자료

댓글 4 / 1 페이지

김보리님의 댓글

전에 구글에서 임의의 선을 그은 후 그 선에 맞춰 연장/트림하는 리습을 봤었습니다.. 소스가 공개된

Ban15님의 댓글

찾은 리습이 위 리습 아래쪽에 사용된 리습인데 아쉬운 점이 있어서 수정해보려합니다 ㅎㅎ

전체 6,983 / 1 페이지
번호
제목
이름

최근글


새댓글


알림 0