style6301 发表于 2007-11-2 15:52:00

如何查找和统计这些块?

<p><font face="宋体" color="#ff0066" size="3">在我的图形中含有多个(上百个)名为“zPanel”的块,</font></p><p><font face="宋体" color="#ff0066" size="3">块中有图号“DrawNO”/色卡“Color”/长度“Len”/宽度“Width”等属性,</font></p><p><font face="宋体" color="#ff0066" size="3">怎么样才能将这些统计数据写入DBF文件中。(已建有相同字段的D:\CYC\DeckP.dbf文件)</font></p>

fjfhgdwfn 发表于 2007-11-3 19:06:00

<p>Sub Example_Select_text() '低等级表形式<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim ssetObj As AcadSelectionSet<br/>&nbsp;&nbsp;&nbsp; Dim CONUT As Integer<br/>&nbsp;&nbsp;&nbsp; CONUT = 0<br/>&nbsp;&nbsp;&nbsp; Count = ThisDrawing.SelectionSets.Count<br/>&nbsp;&nbsp;&nbsp;&nbsp; For I = 0 To Count - 1 '删除所有的选择集<br/>&nbsp;&nbsp;&nbsp; Set ssetObj = ThisDrawing.SelectionSets.Item(0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ssetObj.Delete<br/>&nbsp;&nbsp;&nbsp; Next I<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; Dim sjx, dmx As AcadSelectionSet<br/>&nbsp; <br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp; Dim FilterType(1) As Integer<br/>&nbsp;&nbsp; Dim FilterData(1) As Variant<br/>&nbsp;&nbsp; Set sjx = ThisDrawing.SelectionSets.Add("sjx")<br/>&nbsp;&nbsp; Set dmx = ThisDrawing.SelectionSets.Add("dmx")</p><p>&nbsp;&nbsp; FilterType(0) = 2<br/>&nbsp;&nbsp; FilterData(0) = "TK" '是块名</p><p>&nbsp;&nbsp; 'FilterType(1) = 62<br/>&nbsp;&nbsp; 'FilterData(1) = 10&nbsp; '颜色是3</p><p>&nbsp;&nbsp; FilterType(1) = 8<br/>&nbsp;&nbsp; FilterData(1) = "0"&nbsp; '图层是0<br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp; Dim mode As Integer<br/>&nbsp; Dim doc2 As AcadDocument<br/>&nbsp;Set doc2 = ThisDrawing.ModelSpace.Document<br/>&nbsp;<br/>&nbsp;mode = acSelectionSetAll<br/>&nbsp;'sjx.Select mode, , , FilterType, FilterData<br/>&nbsp; sjx.SelectOnScreen FilterType, FilterData '得到图框<br/>&nbsp;&nbsp;&nbsp; Dim newvarAttributes, inpoint, entry1 As Variant<br/>&nbsp;&nbsp;&nbsp; Dim ss, sss, ssss As String<br/>&nbsp;&nbsp;&nbsp; Dim sjxcount As Integer<br/>&nbsp;&nbsp;&nbsp; sjxcount = sjx.Count<br/>&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; Dim templateFileName As String<br/>&nbsp;&nbsp; Dim DOC1 As AcadDocument<br/>&nbsp;&nbsp;&nbsp; ReDim objects(sjxcount - 1) As AcadEntity<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim retObjects As Variant<br/>&nbsp;&nbsp;&nbsp; Dim minExt As Variant<br/>&nbsp;&nbsp;&nbsp;&nbsp; Dim maxExt As Variant</p><p>&nbsp;&nbsp; <br/>&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; For Each ENTRY In sjx</p><p>&nbsp;&nbsp;&nbsp;&nbsp; newvarAttributes = ENTRY.GetAttributes '得到图框块的属性,即图名图号页码<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; ENTRY.GetBoundingBox minExt, maxExt '得到图框的最大最小坐标<br/>&nbsp;&nbsp;&nbsp;&nbsp; mode = acSelectionSetWindow 'acSelectionSetPrevious 'acSelectionSetCrossing<br/>&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.Application.ZoomWindow minExt, maxExt<br/>&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; dmx.Select mode, minExt, maxExt '选择图框内的对象<br/>&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; ReDim objects(dmx.Count - 1) As AcadEntity<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I = 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each entry1 In dmx<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set objects(I) = entry1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I = I + 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next entry1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set DOC1 = Documents.Add<br/>&nbsp;&nbsp;&nbsp;&nbsp; doc2.CopyObjects objects, DOC1.ModelSpace '拷贝对象到新文件中<br/>&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.Application.ZoomWindow minExt, maxExt<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp; DOC1.SaveAs doc2.Path &amp; "\" &amp; newvarAttributes(1).TextString &amp; "(" &amp; newvarAttributes(2).TextString &amp; ")" &amp; newvarAttributes(0).TextString<br/>&nbsp;&nbsp;&nbsp;&nbsp; DOC1.Close<br/>&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; dmx.Clear<br/>&nbsp;&nbsp;&nbsp;&nbsp; Next ENTRY<br/>&nbsp;&nbsp;&nbsp; </p><p>&nbsp;<br/>&nbsp; <br/>End Sub<br/></p><p>这个功能是实现把0层按块名为“TK”的块,把一张图会成多张。在存文件名时。用到了属性,</p><p>你仔细看下吧。应可以满足你的要求。</p><p></p><p></p>

style6301 发表于 2007-11-5 11:30:00

<font color="#ff0033">十分感谢您的回复,我会认真地研究您提供的源码,谢谢!</font>

style6301 发表于 2007-11-9 09:52:00

<p><font color="#ff0066">我已经顺利的将图块中的属性提取出来,但如何才能形成Visual Foxpro6.0识别的DBF文件?</font></p>
页: [1]
查看完整版本: 如何查找和统计这些块?