龙龙仔
发表于 2004-4-9 17:07:00
1. 问题2好像我没有碰到<BR> 圖中有很多VIEWPORTS有些VIEWPORT像"點"一樣大時,你會發現程序失敗
2. 我想等你過些時日再想解決辦法,目前你是解決不了!
citykunan
发表于 2004-4-10 06:26:00
半夜突然想到如何比较好的解决问题2,忍不住早起开始编程了。
我想了想,好像只能用zoom命令将其放大才行。
龙龙仔
发表于 2004-4-10 07:52:00
;;沒這兩句也"好像"能執行,你真有測試嗎?<BR>;;查一下幫助你會更了解它的作用!!如viewport中ucs並不平行xy平面
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt">好像只能用<SPAN lang=EN-US>zoom命令将其放大才行。</SPAN><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt">->不是每個都zoom,小的才zoom(很麻煩的,試看看)<o:p></o:p>
citykunan
发表于 2004-4-12 08:51:00
版主,我有遇到一个问题,我是想把这个程序扩充到可以用在pline的viewport上。
可是我遇到一奇怪的问题。以下是程序。我用(setq a (car (entsel)))便可以实现,提
取pline上的viewport各节点,并画了一条pline,而用(setq ss_i (ssget '((0 . "VIEWPORT"))))....却不行不知为何?
;这个可以
(defun c:test ()<BR> (setq a (car (entsel)))<BR> ;(setq ss_i (ssget '((0 . "VIEWPORT"))))<BR> ;(setq i 0)<BR> ; (while (< i (sslength ss_i))<BR> ; (setq a (ssname ss_i i))<BR> (setq nlist_list (MASSOC 10 (entget a)))<BR> (setq len_list (length nlist_list ))<BR> (command "_.pline" (setq first_point (car nlist_list)))<BR> (while (setq nlist_list (cdr nlist_list))<BR> (command (car nlist_list))<BR> );enf while<BR> (command first_point "")<BR> ; (setq i (+ i 1))<BR>;);end while<BR>)
(defun massoc (key alist / x nlist)<BR>(foreach x alist<BR>(if (eq key (car x))<BR>(setq nlist (cons (cdr x) nlist))<BR>)<BR>)<BR>(reverse nlist)<BR>)
;这个不行
(defun c:test ()<BR> ;(setq a (car (entsel)))<BR> (setq ss_i (ssget '((0 . "VIEWPORT"))))<BR> (setq i 0)<BR> (while (< i (sslength ss_i))<BR> (setq a (ssname ss_i i))<BR> (setq nlist_list (MASSOC 10 (entget a)))<BR> (setq len_list (length nlist_list ))<BR> (command "_.pline" (setq first_point (car nlist_list)))<BR> (while (setq nlist_list (cdr nlist_list))<BR> (command (car nlist_list))<BR> );enf while<BR> (command first_point "")<BR> (setq i (+ i 1))<BR>);end while<BR>)
(defun massoc (key alist / x nlist)<BR>(foreach x alist<BR>(if (eq key (car x))<BR>(setq nlist (cons (cdr x) nlist))<BR>)<BR>)<BR>(reverse nlist)<BR>)
龙龙仔
发表于 2004-4-12 12:33:00
Pline只是附帶viewport,查看Pline的dxf 330
citykunan
发表于 2004-4-12 13:51:00
版主能不能说的在详细一点,330码怎么用啊?谢谢。
我将330码提出,再用entget取值,还是得不到viewport的节点坐标啊。
龙龙仔
发表于 2004-4-12 14:33:00
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3>那<FONT face="Times New Roman">330</FONT>碼是告訴你這<FONT face="Times New Roman">PLINE</FONT>附帶<FONT face="Times New Roman">VIEWPORT, </FONT>那<FONT face="Times New Roman">VIEWPORT</FONT>的節點就是<FONT face="Times New Roman">PLINE</FONT>的節點<FONT face="Times New Roman">,</FONT>你應該過濾那些<FONT face="Times New Roman">PLINE</FONT>附帶<FONT face="Times New Roman">VIEWPORT</FONT>。<FONT face="Times New Roman">(</FONT>轉一下腦筋好嗎<FONT face="Times New Roman">?)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT>
citykunan
发表于 2004-4-12 15:50:00
在版主的提示下,已经有点眉目,但总是差一点,我已经很努力了,基础太差了。
版主有空时帮我看看我的程序,谢谢了。
(defun C:M_VIEW (/ HOLDECHO HOLDOSMODE A AA<BR> W10 W12 W40 W41 W69 VCTRX VCTRY<BR> LPT RPT INS XP SS ss_i i RT LB len_list<BR> )
(defun DO_IT (CEN)<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> );得出矩形两个角点坐标<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> (leo_sc)<BR> ;(setq A (car (entsel "\nSelect Viewport: ")))<BR> (setq ss_i (ssget '((0 . "LWPOLYLINE,VIEWPORT"))))<BR> (setq i 0)<BR> (while (< i (sslength ss_i))<BR> (setq a (ssname ss_i i))<BR> <BR> (setq nlist_list (MASSOC 10 (entget a)))<BR> (setq len_list (length nlist_list ))<BR> (if (= (cdr (assoc 0 (entget a))) "LWPOLYLINE")<BR> (progn<BR> (command "_.pline" (setq first_point (car nlist_list)))<BR> (while (setq nlist_list (cdr nlist_list))<BR> (command (car nlist_list))<BR> );enf while<BR> (command first_point "")<BR> <BR> (setq BOX (entlast))<BR> <BR> );end progn<BR> <BR> (progn<BR> (setq WDXF (entget A))<BR> (setq XP (/ (cdr (assoc 41 WDXF)) (cdr (assoc 45 WDXF))));-------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> <BR> <BR> (setq W41 (cdr (assoc 41 WDXF)));视图的宽度<BR> (setq W69 (cdr (assoc 69 WDXF)));app:视口的表示数字<BR> (DO_IT W10)<BR> <BR> (if (= (cdr (assoc 0 (entget a))) "VIEWPORT")<BR> (progn <BR> (command "_.rectang" LPT RPT)<BR> (setq BOX (entlast))<BR> )<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> )<BR> (command "_.pspace")<BR> (command "_.ERASE" A "")<BR> );end progn<BR> );end if<BR> (command "zoom" rb lt)<BR> (setq i (+ i 1))<BR>);end whlie<BR> (setvar "osmode" HOLDOSMODE)<BR> (setvar "cmdecho" HOLDECHO)<BR> (command "_.undo" "e")<BR> (princ)<BR>)
;可以做参考,取得绘图窗口坐标<BR>(defun leo_sc (/ ctr size SCREEN SCALE XSIZE) <BR> (command "_.UCS" "V") <BR> (setq CTR (getvar "VIEWCTR")) <BR> (setq SIZE (getvar "VIEWSIZE")) <BR> (setq SCREEN (getvar "SCREENSIZE")) <BR> (setq SCALE (/ (car SCREEN) (cadr SCREEN))) <BR> (setq XSIZE (* SCALE SIZE)) <BR> (setq RT (list (+ (car CTR) (/ XSIZE 2)) (+ (cadr CTR) (/ SIZE 2)))) <BR> (setq LB (list (- (car CTR) (/ XSIZE 2)) (- (cadr CTR) (/ SIZE 2)))) <BR> ;(command "_.line" RT LB "") <BR> ;(command "_.UCS" "P") <BR> (princ) <BR>)
<BR>;得到同一dxf码的多个值,如 (MASSOC 10 (entget (car (entsel)))),可以得到pline的多个节点<BR>(defun massoc (key alist / x nlist)<BR>(foreach x alist<BR>(if (eq key (car x))<BR>(setq nlist (cons (cdr x) nlist))<BR>)<BR>)<BR>(reverse nlist)<BR>)<BR>
龙龙仔
发表于 2004-4-12 16:05:00
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3>你完全看不懂我說的! 8-(<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman">PLINE</FONT>不見得都附帶<FONT face="Times New Roman">VIEWPORT,<o:p></o:p></FONT></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3>能附帶<FONT face="Times New Roman">VIEWPORT</FONT>物件相當多<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman">"circle,ellipse,region,lwpolyline,polyline,spline"</FONT>這些<FONT face="Times New Roman">(closed)</FONT>都可以<o:p></o:p></FONT>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman">(</FONT>多轉<FONT face="Times New Roman">n</FONT>下腦筋好嗎<FONT face="Times New Roman">?)<SPAN style="mso-spacerun: yes"> 8^)</FONT></SPAN></FONT><o:p></o:p>
citykunan
发表于 2004-4-12 16:20:00
版主不要生气,让我这个愚人再试试。