得到图纸空间中所有实体
-
回答:
'得到当前图纸空间中所有实体的代码演示 '当前的图纸空间 Dim curSpace8 As MxDrawXLib.MxDrawBlockTableRecord Set curSpace8 = app.WorkingDatabase.CurrentSpace ' 工具对象,用于向命令行输入出字符串 Dim mxUtility8 As MxDrawXLib.MxDrawUtility Set mxUtility8 = New MxDrawXLib.MxDrawUtility '遍历器,用于遍历当前图纸空间中所有的实体 Dim iter As MxDrawXLib.MxDrawBlockTableRecordIterator Set iter = curSpace8.NewIterator Dim ptDim1 As MxDrawXLib.MxDrawPoint Dim ptDim2 As MxDrawXLib.MxDrawPoint If (iter Is Nothing) Then Exit Sub End If '循环得到所有实体 Do While iter.Done = False ' 得到遍历器当前的实体 Dim ent8 As MxDrawXLib.MxDrawEntity Set ent8 = iter.GetEntity() If (ent8 Is Nothing) = False Then If TypeOf ent8 Is MxDrawXLib.MxDrawText Then '当前实体是个文字实体 Dim text8 As MxDrawXLib.MxDrawText Set text8 = ent8 mxUtility8.Prompt Chr(13) + Chr(10) + text8.TextString ElseIf TypeOf ent8 Is MxDrawXLib.MxDrawPolyline Then '当前实体是一个多义线 Dim polyline As MxDrawXLib.MxDrawPolyline Set polyline = ent8 mxUtility8.Prompt Chr(13) + Chr(10) + "发现Polyline曲线, 下面是它的坐标信息:" '得到Polyline的端点坐标 Dim iNum As Long iNum = 0 Do While iNum < polyline.NumVerts Dim tmpPt As MxDrawXLib.MxDrawPoint Set tmpPt = polyline.GetPointAt(iNum) mxUtility8.Prompt Chr(13) + Chr(10) + "坐标为x:" & tmpPt.x & "y:" & tmpPt.y & "凸度为:" & polyline.GetBulgeAt(iNum) iNum = iNum + 1 Loop ElseIf TypeOf ent8 Is MxDrawXLib.MxDrawDimAligned Then Dim dimAligned8 As MxDrawXLib.MxDrawDimAligned Set dimAligned8 = ent8 mxUtility8.Prompt Chr(13) + Chr(10) + dimAligned8.DimensionText '当DimensionText返回为空时,可以用下面的ptDim1,ptDim2两点的距离算出标注内容。 Set ptDim1 = dimAligned8.XLine1Point Set ptDim2 = dimAligned8.XLine2Point ElseIf TypeOf ent8 Is MxDrawXLib.MxDrawDimRotated Then Dim dimRotated8 As MxDrawXLib.MxDrawDimRotated Set dimRotated8 = ent8 mxUtility8.Prompt Chr(13) + Chr(10) + dimRotated8.DimensionText '当DimensionText返回为空时,可以用下面的ptDim1,ptDim2两点的距离算出标注内容。 Set ptDim1 = dimRotated8.XLine1Point Set ptDim2 = dimRotated8.XLine2Point ' ElseIf TypeOf ent8 Is 其它类型 Then ' ... ... End If End If iter.Step Loop
-
回答:
主要用到函数说明:
IMxDrawSelectionSet::Select
构造选择集。详细说明如下:
参数 说明 [in] MCAD_McSelect Mode
构造选择集方式
[in] VARIANT point1
构造择择集时需要使用到的点对象
[in] VARIANT point2
构造择择集时需要使用到的点对象
[in,optional] VARIANT filterData
构造选择集的过滤数据
可以取如下值
mcSelectionSetWindow = 0, mcSelectionSetCrossing = 1, mcSelectionSetFence = 2, mcSelectionSetPrevious = 3, mcSelectionSetLast = 4, mcSelectionSetAll = 5, 选择图面上的所有实体 mcSelectionSetWindowPolygon = 6, mcSelectionSetCrossingPolygon = 7, mcSelectionSetUserSelect = 8 mcSelectionImpliedSelectSelect = 9,_I 返回当前图上已经选择的实体