- 积分
- 1819
- 明经币
- 个
- 注册时间
- 2010-10-9
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
请大侠诊断一下,以下代码,不知为何,就是选不中 关联的 含有同样Xdata的所有实体!
请多指点!!
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
‘############################### 根据实体ID获取实体
For Each odj As ObjectId In Path_EntObjID
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim poly_ent As Polyline = DirectCast(tr.GetObject(odj, OpenMode.ForRead), Polyline) '处理
Dim returnCADObj_ObjectID As Object
Dim DtHash As Object
Dim order_FinalPline As Object
Dim rbw As ResultBuffer = poly_ent.GetXDataForApplication("Vhelr")
For Each m_value As TypedValue In rbw
If m_value.TypeCode = 1040 Then
returnCADObj_ObjectID = m_value.Value
ElseIf m_value.TypeCode = 1071 Then
DtHash = m_value.Value
ElseIf m_value.TypeCode = 1070 Then
order_FinalPline = m_value.Value
End If
Next
MsgBox(returnCADObj_ObjectID.ToString + " " + DtHash.ToString + " " + order_FinalPline.ToString)
For path_EntN = 0 To poly_ent.NumberOfVertices - 1
Dim values2 As TypedValue = New TypedValue(DxfCode.ExtendedDataReal, returnCADObj_ObjectID)
Dim values3 As TypedValue = New TypedValue(DxfCode.ExtendedDataInteger32, DtHash)
Dim values4 As TypedValue = New TypedValue(DxfCode.ExtendedDataControlString, path_EntN)
Dim values() As TypedValue = { values2, values3, values4}
Dim filter As New SelectionFilter(values)
Dim resSel As PromptSelectionResult = ed.SelectAll(filter) '发生了Selectadded
If resSel.Status = PromptStatus.OK Then
'获取选择集中的Polyline对象
Dim sSet As SelectionSet = resSel.Value
Dim idsS As ObjectId() = sSet.GetObjectIds()
For Each M_id As ObjectId In idsS
Dim followedPolyline As Polyline = DirectCast(tr.GetObject(M_id, OpenMode.ForRead), Polyline)
Dim mrbw As ResultBuffer = followedPolyline.GetXDataForApplication("Cutting_path")
For Each m_value As TypedValue In mrbw
If m_value.TypeCode = 1071 Then
MsgBox("对应的路径的实体的ID是 " & followedPolyline.ObjectId.ToString)
End If
Next
Next M_id
Else
MsgBox("没有相应的实体被选")'############# 始终在这里 显示Msg,没有对象被选择
End If
Next
tr.Commit() '提交
End Using
End If
Next
请高人指正!!
|
|