Public Sub GetAddressList(ByVal ed As Editor)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim values() As TypedValue = {New TypedValue(DxfCode.ExtendedDataRegAppName, "PLCHOUSENUMBER"), _
New TypedValue(DxfCode.LayoutName, "MODEL")}
Dim sfilter As New SelectionFilter(values)
Dim Res As PromptSelectionResult
ed.WriteMessage(vbLf & "Выберите дома для нового кластера.")
ed.UpdateScreen()
Dim pKeyOpts As PromptKeywordOptions = New PromptKeywordOptions("")
pKeyOpts.Message = vbLf & "Каким методом выбора объекта вы хотите воспользоваться?"
pKeyOpts.Keywords.Add("Полигон")
pKeyOpts.Keywords.Add("Одиночно")
pKeyOpts.AllowNone = False
Dim pKeyRes As PromptResult = ed.GetKeywords(pKeyOpts)
Select Case pKeyRes.StringResult
Case "Полигон"
Dim entOpt As PromptEntityOptions
entOpt = New PromptEntityOptions("\nВыберите полилинию:")
entOpt.SetRejectMessage("Это не полилиния!")
entOpt.AddAllowedClass(GetType(Polyline), True)
Dim entRes As PromptEntityResult
entRes = ed.GetEntity(entOpt)
If entRes.Status <> PromptStatus.OK Then
Exit Sub
End If
Dim pLineId As ObjectId = entRes.ObjectId
Dim gripPts As Point3dCollection = New Point3dCollection()
Dim pline As Polyline
Using MyT As Transaction = db.TransactionManager.StartTransaction()
pline = MyT.GetObject(pLineId, OpenMode.ForRead)
pline.GetGripPoints(gripPts, New IntegerCollection(), New IntegerCollection())
' MyT.AddNewlyCreatedDBObject(gripPts, True)
MyT.Commit()
MyT.Dispose()
End Using
Res = ed.SelectCrossingPolygon(gripPts, sfilter)
' Res = ed.GetEntity(peo)
Case "Одиночно"
Res = ed.GetSelection(sfilter)
End Select
If Res.Status = PromptStatus.Error Then
ed.WriteMessage(ControlChars.CrLf)
ed.WriteMessage("Чертеж не содержит номеров домов.")
ed.UpdateScreen()
Return
End If
Using MyT As Transaction = db.TransactionManager.StartTransaction()
Dim acBlkTbl As BlockTable
acBlkTbl = MyT.GetObject(db.BlockTableId, OpenMode.ForRead)
'Dim acBlkTblRec As BlockTableRecord
'acBlkTblRec = MyT.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
End Using
Dim SS As Autodesk.AutoCAD.EditorInput.SelectionSet = Res.Value
Dim IdArray As ObjectId() = SS.GetObjectIds()
Dim Id As ObjectId
Dim c As Long = 0
ReDim ad(SS.Count - 1)
Using MyT As Transaction = db.TransactionManager.StartTransaction()
For Each Id In IdArray
Dim hn As BlockReference = MyT.GetObject(Id, OpenMode.ForRead)
Dim rs As Array = hn.GetXDataForApplication("ESTATE_DATAS").AsArray()
Dim rsFID As ResultBuffer = hn.GetXDataForApplication("FID")
If rsFID = Nothing Then
Else
ad(c).Fid = rsFID.AsArray(2).Value
End If
c = c + 1
Next
End Using
ad = GetExcelData(ad)
Dim AdData As AddressDatas
Dim quartes As Integer
quartes = 0
For Each AdData In ad
quartes = quartes + AdData.Quarters
Next
Dim s As StringBuilder = New StringBuilder()
s.Append("В выбраных домах количество квартир равняется ")
s.Append(quartes)
ed.WriteMessage(s.ToString())
ed.WriteMessage(ControlChars.CrLf)
ed.UpdateScreen()
BuildAddressTable(ed, ad)
End Sub