Can#039;t移除#039;用户i
大家好,我有KEAN WALMSLEY的密码。
他的代码将要求用户选择一个块,然后列出所有选定块的属性。然而,我需要稍微调整他的代码,而不是用户交互,块必须通过其名称和我的代码来选择。
以下是他的代码(根据我的目的稍作修改):
Private Sub ListAttributes()
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Try
Dim filList As TypedValue() = New TypedValue(0) {New TypedValue(CInt(DxfCode.Start), "INSERT")}
Dim filter As New SelectionFilter(filList)
Dim opts As New PromptSelectionOptions()
opts.MessageForAdding = "Select block references: "
Dim res As PromptSelectionResult = ed.GetSelection(opts, filter)
If res.Status <> PromptStatus.OK Then
Return
End If
Dim selSet As SelectionSet = res.Value
Dim idArray As ObjectId() = selSet.GetObjectIds()
For Each blkId As ObjectId In idArray
Dim blkRef As BlockReference = DirectCast(tr.GetObject(blkId, OpenMode.ForRead), BlockReference)
Dim btr As BlockTableRecord = DirectCast(tr.GetObject(blkRef.BlockTableRecord, OpenMode.ForRead), BlockTableRecord)
ed.WriteMessage(vbLf & "Block: " + btr.Name)
btr.Dispose()
Dim attCol As AttributeCollection = blkRef.AttributeCollection
For Each attId As ObjectId In attCol
Dim attRef As AttributeReference = DirectCast(tr.GetObject(attId, OpenMode.ForRead), AttributeReference)
Dim str As String = (vbLf & attRef.Tag + " " & attRef.TextString)
ed.WriteMessage(str)
Next
Next
tr.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(("Exception: " + ex.Message))
Finally
tr.Dispose()
End Try
End Sub
现在,我需要将此Sub更改为如下函数:
Private Function ListAttributes (blockName As String) As Boolean
如果图形中存在“blockName”,则目标是列出所有块属性,然后返回True。相反,如果blockName不存在,它应该返回我False,并且不向编辑器打印任何内容。
谁能帮帮我吗?
干杯 请停止重复投递
我已经回答了讨论小组的问题 我的道歉。不知道pro用户同时监视两个CAD论坛,
无论如何,谢谢你。 没问题,这只是Acad论坛的常见规则
干杯
页:
[1]