[原创]线换向程序
;;;线换向(DEFUN c:fx (/ acoords ename ename1 etype1 npts num1 pts pt_end pt_start ss1 vobj1)
(SETQ ss1 (SSGET '((0 . "LINE,MLINE,SPLINE,POLYLINE,LWPOLYLINE"))))
(IF (= 'ename (TYPE ss1))
(SETQ ss1 (SSADD ename))
)
(SETQ num1 0)
(REPEAT (IF ss1
(SSLENGTH ss1)
0
)
(SETQ ename1 (SSNAME ss1 num1)
vobj1 (VLAX-ENAME->VLA-OBJECT ename1)
etype1 (CDR (ASSOC '0 (ENTGET ename1)))
num1 (1+ num1)
)
(COND
;;LINE:调换首尾点
((= "LINE" etype1)
(SETQ pt_start (VLA-GET-STARTPOINT vobj1)
pt_end (VLA-GET-ENDPOINT vobj1)
)
(IF (OR (VLA-PUT-STARTPOINT vobj1 pt_end) (VLA-PUT-ENDPOINT vobj1 pt_start))
(*error* "不能更新对象数据。")
)
)
;;SPLIN:调用Reverse反向
((= "SPLINE" etype1)
(VLA-REVERSE vobj1)
)
;;POLYLINE,LWPOLYLINE:坐标对调
((WCMATCH etype1 "MLINE,POLYLINE,LWPOLYLINE")
(SETQ acoords (VLAX-VARIANT-VALUE (VLA-GET-COORDINATES vobj1))
pts (IF (> (VLAX-SAFEARRAY-GET-U-BOUND acoords 1) (VLAX-SAFEARRAY-GET-L-BOUND acoords 1))
(VLAX-SAFEARRAY->LIST acoords)
)
npts (LIST)
)
(IF (= "LWPOLYLINE" etype1)
(WHILE pts
(SETQ npts (CONS (CAR pts) (CONS (CADR pts) npts))
pts (CDDR pts)
)
)
(WHILE pts
(SETQ npts (CONS (CAR pts) (CONS (CADR pts) (CONS (CADDR pts) npts)))
pts (CDDDR pts)
)
)
) ;_对调坐标
(IF (VLA-PUT-COORDINATES vobj1 (VLAX-SAFEARRAY-FILL acoords npts))
(*error* "不能更新对象数据。")
)
)
)
(VLA-UPDATE vobj1)
)
(PRINC)
)对同一POLYLINE使用VLA-GET-COORDINATES后,不能用PEDIT改变拟合状态,否则再用VLA-GET-COORDINATES就会出现“Automation 错误。未提供说明。”不知大家有何良策? 对有弧线段的pl线,换向后凸度也变了 :( 呵呵. 我下載試用一下先.
哈. 謝樓主. 這個可幫了我一個忙. 我用來完善那個把兩條曲線焊接成一條的LISP. 送朵花以表謝意. <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman">;;</FONT>可有判断顺时针<FONT face="Times New Roman">OR</FONT>逆时针方法<FONT face="Times New Roman">(FOR SPLINE,LWPOLYLINE,POLYLINE)</FONT></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman">;;By LUCAS(</FONT>龙龙仔<FONT face="Times New Roman">)</FONT></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman">;;</FONT>线换向程序</FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman" size=3>;;FOR LWPOLYLINE ONLY</FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman" size=3>(defun C:TEST (/ ENT ENT1 Q Q1 Q3 Q4 N)</FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (setq ENT (entget (setq ENT1 (car (entsel)))))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (setq Q (reverse (member (assoc 39 (reverse ENT)) (reverse ENT))))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (setq Q1 (member (assoc 10 ENT) ENT))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (setq N 0</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> Q3 NIL</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> )</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (repeat (/ (- (length Q1) 1) 4)</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (setq Q3 (append Q3</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (list (nth </SPAN><?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:place>N Q1</st1:place>)</FONT></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (cons 42 (* -1 (cdr (nth (+ N 3) Q1))))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (cons 41 (cdr (nth (+ N 1) Q1)))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (cons 40 (cdr (nth (+ N 2) Q1)))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> )</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> )</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> )</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (setq N (+ N 4))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> )</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (setq Q3 (reverse Q3))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (entmake (append Q</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (member (assoc 10 Q3) Q3)</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (list (nth 0 Q3))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (list (nth 1 Q3))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (list (nth 2 Q3))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (list (last Q1))</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> )</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> )</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (entdel ENT1)</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (princ)</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman" size=3>)</FONT> <P><FONT size=3>奇怪,<FONT face="Times New Roman">(</FONT>龙龙仔<FONT face="Times New Roman">)的对于拟合后的换向后原来的线条没有了,对于没有拟合还正常。</FONT></FONT></P>
页:
[1]