正在检查块是否存在。。
您好,我如何检查某个块是否存在或插入到图形中,该图形可以位于任何布局或模型空间中,而无需在布局中循环检查是否使用ThisDrawing.Blocks。项目(“)?我想按名称检查,真的,一个名为“的块;“固定图”
你可以这样做:
Function BlockExists(ByRef blockName as String) as Boolean
Dim block as AcadBlock
On Error Resume Next
Set block = ThisDrawing.Blocks(blockName)
If Err = 0 then
BlockExists = True
Else
BlockExists = False
End If
Err.Clear
On Error Goto 0
Set block = Nothing
End Function
;我通常不喜欢内联错误处理,但有时也有例外。 或使用选择集搜索Set sset1 = ThisDrawing.SelectionSets.Add("SSbks")
Dim FilterType(0 To 1) As Integer
Dim FilterData(0 To 1) As Variant
FilterType(0) = 0: FilterData(0) = "INSERT"
FilterType(1) = 2: FilterData(1) = "MyBlockName"
sset1.Select acSelectionSetAll, , , FilterType, FilterData 然后检查选择集计数,如果sset1.count=0,则块不';t存在
哎呀 ;我想我没有';我读得不够仔细 ;我的只会告诉你块表中是否存在块定义。
原始请求要求;检查是否存在某个块;(你的人是这样做的)-或;插入到图形中;,(亨迪是这样做的)-所以我认为这篇文章涵盖了。。。 您好,谢谢你们两位的输入。好的,用这两个选项中的任何一个,检查块是否存在,如何检查属性值。现在我知道我只能在插入块引用的情况下检查它们,所以我知道我现在可以检查块集合中是否存在块,但我需要检查的是是否插入了一个块,但没有在所有布局中循环,我希望它几乎是即时的,所以当用户窗体加载时,它检查插入的块并在表单上显示属性值。我可以进行属性检查并填充表单,它只检查插入的图块,而不检查我不检查的每个布局;我不知道 啊,对不起,当最后两篇帖子进来时,我正在输入,哈哈 您好,所以使用Hendie#039;s代码:
Set sset1 = ThisDrawing.SelectionSets.Add("SSbks")
Dim FilterType(0 To 1) As Integer
Dim FilterData(0 To 1) As Variant
FilterType(0) = 0: FilterData(0) = "INSERT"
FilterType(1) = 2: FilterData(1) = "MyBlockName"
sset1.Select acSelectionSetAll, , , FilterType, FilterData 如何访问块,选择集中的对象是什么状态?它是一个AcadEntity,还是一个AcadObject或AcadBlockReference,还是作为其他内容存储在选择集中。我现在想从这里访问属性,但是为了检查它是正确的对象类型,我需要放置什么/选择集中项目的变量名是什么
希望你能理解我,哈哈。。 我的意思是,我有这个代码:
attribX = BlockX.GetAttributes
For countz = LBound(attribX) To UBound(attribX)
Select Case attribX(countz).TagString
Case "FIX1"
fx1descTXT.text = attribX(countz).TextString
Case "FIX2"
fx2descTXT.text = attribX(countz).TextString
Case "FIX3"
fx3descTXT.text = attribX(countz).TextString
Case "FIX4"
fx4descTXT.text = attribX(countz).TextString
Case "FIX5"
fx5descTXT.text = attribX(countz).TextString
Case "FIX6"
fx6descTXT.text = attribX(countz).TextString
Case "FIX7"
fx7descTXT.text = attribX(countz).TextString
Case "FIX8"
fx8descTXT.text = attribX(countz).TextString
Case "FIX9"
fx9descTXT.text = attribX(countz).TextString
Case "FIX10"
fx10descTXT.text = attribX(countz).TextString
End Select
Next 'End countx HasAttributes check loop.. 那么我该如何将其与选择集代码联系起来呢?我已经将BlockX标注为AcadBlockReference,但这对ss中的内容正确吗? 好吧,这个想法让我思考,这是我可以经常使用的东西。不是属性部分,而是找出块是否存在。奇怪的是,它还可以用来计算特定块的插入次数…所以这是给所有后代的…
页:
[1]
2