下载源码 发表于 2006-9-21 10:46:00

如何判断一个匿名块是否被删除

<P>问题背景:</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 尺寸标注是以匿名块的形式存在的。根据标注的先后顺序CAD给每个标注一个识别代码(*D1、*D2、*D3...依次类推),当其中某个尺寸标注被删除后,在该DWG文件再次打开之前,一直都是能读取的(只保存不关闭,匿名块还是能读取到的),但在该DWG文件再次打开后,被删除的标注就不能读取到了。意思就是DWG文件在保存关闭的时候才把被删除的匿名块给过虑掉。</P>
<P>问题:</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CAD是如何判断匿名块被删除的呢?</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 特请教高手,谢谢!!!</P>

mccad 发表于 2006-9-21 13:22:00

这是ACAD本身内部系统的问题,并不需要你去了解。匿名块本身就这样的特性。

下载源码 发表于 2006-9-21 17:43:00

<P>我想了解问题的原因在于,最近我在做个小程序,给尺寸标注自动编号,编号能修改,而且随着尺寸的删除而删除,编号始终是连贯的,从1开始。。。中间某个编号被修改或删除,则编号自动调整。</P>
<P>在实现自动连续编号的过程中,我发现那些被删除的尺寸也添加上了编号,这是不应该出现的,我怎么查找这些已经被删除的标注块呢,应该有尺寸块删除标志的吧。</P>
<P>尝试了一些想法,还是没找出问题的关键。</P>
<P>老大们,有什么办法吗???</P>
<P>谢谢!!!</P>

mccad 发表于 2006-9-21 21:54:00

对每个以*D开头的匿名块,用块名称查看图中是否存在块(选择集过滤)。如果没有,则说明该标注已经不存在。

下载源码 发表于 2006-9-23 13:48:00

<P>谢谢明总!</P>
<P>我试了下,还是搞不定,不知问题出在哪里,帮忙看看。</P>
<P>下面是模块里的代码:</P>
<P>Public Sub CreateSSetFilter(ByRef filterType As Variant, ByRef filterData As Variant, ParamArray filter())<BR>&nbsp;&nbsp;&nbsp; 'MsgBox UBound(filter)<BR>&nbsp;&nbsp;&nbsp; If UBound(filter) Mod 2 = 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "filter参数无效!"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim fType() As Integer<BR>&nbsp;&nbsp;&nbsp; Dim fData() As Variant<BR>&nbsp;&nbsp;&nbsp; Dim count As Integer<BR>&nbsp;&nbsp;&nbsp; count = (UBound(filter) + 1) / 2<BR>&nbsp;&nbsp;&nbsp; ReDim fType(count - 1)<BR>&nbsp;&nbsp;&nbsp; ReDim fData(count - 1)<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp;&nbsp; For i = 0 To count - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fType(i) = filter(2 * i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fData(i) = filter(2 * i + 1)<BR>&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; filterType = fType<BR>&nbsp;&nbsp;&nbsp; filterData = fData<BR>End Sub</P>
<P>下面是Thisdrawing中的代码:</P>
<P>Public Sub FilterSSet()<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; On Error Resume Next<BR>&nbsp;&nbsp;&nbsp; Dim SSet As AcadSelectionSet<BR>&nbsp;&nbsp;&nbsp; If Not IsNull(ThisDrawing.SelectionSets.Item("Example")) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set SSet = ThisDrawing.SelectionSets.Item("Example")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SSet.Delete<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Set SSet = ThisDrawing.SelectionSets.Add("Example")<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim fType As Variant, fData As Variant<BR>&nbsp;&nbsp;&nbsp; Call CreateSSetFilter(fType, fData, 2, "*D*", 8, "0")<BR>&nbsp;&nbsp;&nbsp; SSet.Select acSelectionSetAll, , , fType, fData<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; MsgBox SSet.count<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; SSet.Delete<BR>End Sub</P>
<P>&nbsp;</P>
<P>测试结果 显示 为 0</P>
<P><BR>&nbsp;</P>
页: [1]
查看完整版本: 如何判断一个匿名块是否被删除