龙龙仔
发表于 2004-4-22 10:02:00
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman">1.<SPAN style="FONT: 7pt 'Times New Roman'"> </FONT></SPAN></SPAN><FONT size=3>在select object時輸入all是不是不經過過濾了或是選的更加多了?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">->ALL</FONT>選項會得到所有<FONT face="Times New Roman">LWPOLYLINE,VIEWPORT(</FONT>當然有過濾<FONT face="Times New Roman">)<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">-></FONT>沒有附帶<FONT face="Times New Roman">VIEWPORT</FONT>的<FONT face="Times New Roman">LWPOLYLINE</FONT>也在其中<FONT face="Times New Roman">(</FONT>你要改進這一點<FONT face="Times New Roman">)<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">-></FONT>所有圖紙空間的<FONT face="Times New Roman">VIEWPORT</FONT>也在其中<FONT face="Times New Roman">(</FONT><FONT size=3>69碼的判斷把它解決了)<o:p></o:p></FONT>
<P class=tablebody style="MARGIN: auto 0cm"><FONT face=新細明體>2.<SPAN style="mso-spacerun: yes"> DXF69是</SPAN><FONT size=3>Viewport ID , (69 . 1)就是圖紙空間</FONT></FONT>
<P class=tablebody style="MARGIN: auto 0cm"><FONT size=3><FONT face=新細明體><SPAN style="mso-spacerun: yes"> 下到程序列出所有VIEWPORT的ENTGET</FONT></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">(setq SS (ssget "X" '((0 . "VIEWPORT")))<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> N 0<o:p></o:p></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">)<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">(repeat<SPAN style="mso-tab-count: 1"> (sslength SS)<o:p></o:p></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (print (entget (ssname SS N)))<o:p></o:p></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (setq N (1+ N))<o:p></o:p></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">)<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><o:p><FONT face="Times New Roman"> </FONT></o:p>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><o:p><FONT face="Times New Roman"> </FONT></o:p>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2; tab-stops: list 18.0pt"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman">3.<SPAN style="FONT: 7pt 'Times New Roman'"> </FONT></SPAN></SPAN>重點<FONT face="Times New Roman">: ALL</FONT>選項打破了<FONT face="Times New Roman">LWPOLYLINE</FONT>後續是附帶<FONT face="Times New Roman">VIEWPORT</FONT>的規則<FONT face="Times New Roman">(</FONT>難怪<FONT face="Times New Roman">!</FONT>我從未聽說過<FONT face="Times New Roman">,</FONT>不要再用這不穩定的規則<FONT face="Times New Roman">)<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> <o:p></o:p></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">(setq SS (ssget "X" '((0 . "LWPOLYLINE,VIEWPORT")))<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> N 0<o:p></o:p></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">)<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">(repeat<SPAN style="mso-tab-count: 1"> (sslength SS)<o:p></o:p></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (print (entget (ssname SS N)))<o:p></o:p></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"> (setq N (1+ N))<o:p></o:p></FONT></SPAN>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><FONT face="Times New Roman">)<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><o:p><FONT face="Times New Roman"> </FONT></o:p>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><o:p><FONT face="Times New Roman"> </FONT></o:p>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><o:p><FONT face="Times New Roman"></FONT></o:p>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><o:p><FONT face="Times New Roman">PS:結論:你再想辦法吧!不行我再來!</FONT></o:p>
龙龙仔
发表于 2004-5-14 13:41:00
;;以圖塊方式從模型空間轉圖紙空間(PLINE VIEWPORT)<BR>;;不含炸開圖塊後保持原樣(指尺寸標註)<BR>;;BY 龍龍仔(LUCAS)<BR>(defun C:M_VIEW (/ LPT RPT VP HOLDECHO<BR> HOLDOSMODE SS_I SS_P SS_V I<BR> SSD_P A N BOX<BR> )<BR> (vl-load-com)<BR> (defun DO_IT1 (VP FLAG / WDXF XP W10 W12 W40 W69 SS AA)<BR> (setq WDXF (entget VP))<BR> (setq XP (/ (cdr (assoc 41 WDXF)) (cdr (assoc 45 WDXF))))<BR> ;;-------45號碼是什麼用的?好像是個比例因數,我研究下來發現可以得到viewport的比例<BR> ;;經多次研究發現41號碼除以45號碼總能得到viewport的比例<BR> (setq W10 (cdr (assoc 10 WDXF))) ;viewport視圖的中點<BR> (setq W12 (cdr (assoc 12 WDXF))) ;wcs下的目標點<BR> (setq W40 (cdr (assoc 40 WDXF))) ;視圖的高度<BR> (setq W41 (cdr (assoc 41 WDXF))) ;視圖的寬度<BR> (setq W69 (cdr (assoc 69 WDXF))) ;app:視口的表示字<BR> (if (> W69 1)<BR> (progn<BR> (DO_IT W10)<BR> (if FLAG<BR> (progn<BR> (command "_.rectang" LPT RPT)<BR> (setq BOX (entlast))<BR> )<BR> )<BR> (command "zoom" LPT RPT)<BR> (setq W40 (/ W40 XP))<BR> (setq W41 (/ W41 XP))<BR> (command "_.MSPACE")<BR> (setvar "cvport" W69)<BR> (command "_.ucs" "v")<BR> (DO_IT W12) ;得到相應大小的矩形框。<BR> (setq SS (ssget "c" RPT LPT))<BR> (if SS<BR> (progn<BR> (setq AA (rtos (* (getvar "CDATE") 1E8))) ;做塊名<BR> (command "_.block" AA W12 SS "")<BR> (command "_.oops") ;undo erase<BR> (command "_.pspace")<BR> (command "_.insert" AA W10 XP "" "")<BR> (command "_.xclip" (entlast) "" "N" "S" BOX)<BR> )<BR> ) ;end if<BR> )<BR> )<BR> (command "_.pspace")<BR> ) ;end progn
(defun DO_IT (CEN / VCTRX VCTRY)<BR> (setq VCTRX (car CEN))<BR> (setq VCTRY (cadr CEN))<BR> (setq LPT (list (- VCTRX (/ W40 2.0)) (- VCTRY (/ W41 2.0))))<BR> (setq RPT (list (+ VCTRX (/ W40 2.0)) (+ VCTRY (/ W41 2.0))))<BR> ) ;得出矩形兩個角點座標
(setq HOLDECHO (getvar "cmdecho"))<BR> (setq HOLDOSMODE (getvar "osmode"))<BR> (setvar "cmdecho" 0)<BR> (command "_.undo" "be")<BR> (setvar "osmode" 0)<BR> (command "_.PSPACE")<BR> (setq SS_I (ssget '((0 . "LWPOLYLINE,VIEWPORT"))))<BR> (if SS_I<BR> (progn<BR> (setq SS_V (ssget "P" '((0 . "VIEWPORT"))))<BR> (command "_.SELECT" SS_I "")<BR> (setq SS_P (ssget "P" '((0 . "LWPOLYLINE"))))<BR> (command "_.VIEW" "S" "M_VIEW")<BR> )<BR> )<BR> (if SS_P<BR> (progn<BR> (setq N 0<BR> SSD_P (ssadd)<BR> )<BR> (repeat (sslength SS_P)<BR> (setq A (ssname SS_P N))<BR> (if<BR> (and<BR> (= (cdr (assoc 0 (entget A))) "LWPOLYLINE")<BR> (= (cdr<BR> (assoc 0<BR> (entget (setq VP (cdr (assoc 330 (entget A)))))<BR> )<BR> )<BR> "VIEWPORT"<BR> )<BR> )<BR> (progn<BR> (entmake<BR> (vl-remove-if '(lambda (X) (= 330 (car X))) (entget A))<BR> )<BR> (setq BOX (entlast))<BR> (DO_IT1 VP NIL)<BR> )<BR> (ssadd A SSD_P)<BR> )<BR> (setq N (1+ N))<BR> )<BR> (command "_.ERASE" SS_P "R" SSD_P "")<BR> )<BR> )<BR> (if SS_V<BR> (progn<BR> (setq N 0)<BR> (repeat (sslength SS_V)<BR> (setq VP (ssname SS_V N))<BR> (if (entget VP)<BR> (DO_IT1 VP t)<BR> )<BR> (setq N (1+ N))<BR> )<BR> (command "_.ERASE" SS_V "")<BR> )<BR> )<BR> (command "_.VIEW" "R" "M_VIEW")<BR> (command "_.VIEW" "D" "M_VIEW")<BR> (setvar "osmode" HOLDOSMODE)<BR> (setvar "cmdecho" HOLDECHO)<BR> (command "_.undo" "e")<BR> (princ)<BR>)<BR>(prompt "\nType M_VIEW to run")<BR>(princ)
<BR>;;反向操作,從VIEWPORT中也有DXF340碼記錄了VIEWPORT是由某LWPOLYLINE建成<BR>;;程序可否再寫一次<BR>;;By 龍龍仔(LUCAS)<BR>(defun C:M_VIEW_LAI (/ LPT RPT HOLDECHO HOLDOSMODE<BR> SS_I SS_D SS_V I A BOX WDXF<BR> XP W10 W12 W40 W41 W69 SS<BR> ENT<BR> )
(defun DO_IT (CEN / VCTRX VCTRY)<BR> (setq VCTRX (car CEN))<BR> (setq VCTRY (cadr CEN))<BR> (setq<BR> LPT (list (- VCTRX (/ W40 2.0)) (- VCTRY (/ W41 2.0)))<BR> )<BR> (setq<BR> RPT (list (+ VCTRX (/ W40 2.0)) (+ VCTRY (/ W41 2.0)))<BR> )<BR> )
(setq HOLDECHO (getvar "cmdecho"))<BR> (setq HOLDOSMODE (getvar "osmode"))<BR> (setvar "cmdecho" 0)<BR> (setvar "osmode" 0)<BR> (command "_.undo" "be")<BR> (command "_.PSPACE")<BR> (setq SS_I (ssget '((0 . "LWPOLYLINE,VIEWPORT"))))<BR> (setq SS_V (ssget "P" '((0 . "VIEWPORT") (-4 . ">") (69 . 1))))<BR> (setq I 0<BR> SS_D (ssadd)<BR> )<BR> (if SS_V<BR> (progn<BR> (command "_.VIEW" "S" "M_VIEW")<BR> (while (< I (sslength SS_V))<BR> (setq A (ssname SS_V I)<BR> BOX NIL<BR> )<BR> (if (setq ENT (assoc 340 (entget A)))<BR> (progn<BR> (entmake (vl-remove-if<BR> '(lambda (X) (= 330 (car X)))<BR> (entget (cdr ENT))<BR> )<BR> )<BR> (setq BOX (entlast))<BR> (ssadd (cdr ENT) SS_D)<BR> )<BR> )<BR> (setq WDXF (entget A))<BR> (setq XP (/ (cdr (assoc 41 WDXF)) (cdr (assoc 45 WDXF))))<BR> (setq W10 (cdr (assoc 10 WDXF)))<BR> (setq W12 (cdr (assoc 12 WDXF)))<BR> (setq W40 (cdr (assoc 40 WDXF)))<BR> (setq W41 (cdr (assoc 41 WDXF)))<BR> (setq W69 (cdr (assoc 69 WDXF)))<BR> (DO_IT W10)<BR> (if (not BOX)<BR> (progn<BR> (command "_.rectang" LPT RPT)<BR> (setq BOX (entlast))<BR> )<BR> )<BR> (command "zoom" LPT RPT)<BR> (setq W40 (/ W40 XP))<BR> (setq W41 (/ W41 XP))<BR> (command "_.MSPACE")<BR> (setvar "cvport" W69)<BR> (command "_.ucs" "v")<BR> (DO_IT W12)<BR> (setq SS (ssget "c" RPT LPT))<BR> (if SS<BR> (progn<BR> (setq AA (rtos (* (getvar "CDATE") 1E8)))<BR> (command "_.block" AA W12 SS "")<BR> (command "_.oops")<BR> (command "_.pspace")<BR> (command "_.insert" AA W10 XP "" "")<BR> (command "_.xclip" (entlast) "" "N" "S" BOX)<BR> )<BR> )<BR> (command "_.pspace")<BR> (setq I (+ I 1))<BR> )<BR> (command "_.ERASE" SS_D SS_V "")<BR> (command "_.VIEW" "R" "M_VIEW")<BR> (command "_.VIEW" "D" "M_VIEW")<BR> )<BR> )<BR> (setvar "osmode" HOLDOSMODE)<BR> (setvar "cmdecho" HOLDECHO)<BR> (command "_.undo" "e")<BR> (princ)<BR>)<BR>(prompt "\nType M_VIEW to run")<BR>(princ)<BR>
citykunan
发表于 2004-5-14 14:32:00
谢谢斑主,让我先研究一下。
vken7az2p
发表于 2006-2-23 07:14:00
请问(rtos (* (getvar "CDATE") 1E8)))这段程序中的 1E8 所代表涵义为何呢<BR>烦请各位可以解答一下<BR>谢谢
maomao2004
发表于 2006-2-23 08:46:00
1e8=1*10^8
caoyin
发表于 2006-2-27 10:55:00
<P><STRONG>Express Tools 菜单下的CHSPACE命令,很管用</STRONG></P>
<P> </P>
自贡黄明儒
发表于 2013-9-3 16:35:07
04年高手就在这里对决了,很了不起