<CommandMethod("STPR-SVPlanImport")>
Public Sub STPR_SVPlanImport()
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim ed As Editor = acDoc.Editor
Dim CivilDoc As CivilDocument = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument()
Dim mapApp As MapApplication = HostMapApplicationServices.Application
Dim activeProject As Project.ProjectModel = mapApp.ActiveProject
Dim tableList As ObjectData.Tables = activeProject.ODTables
Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView()
'Dim docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim acBlkTbl As BlockTable = acTrans.GetObject(acCurDb.BlockTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
Dim acBlkTblRec As BlockTableRecord = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Dim aliasList As Aliases = mapApp.Aliases
Dim PutchDWG As String = "c:\захаров\Civil3D(x64)2015\Civil3D(x64)2015\bin\Debug\Запрос в Map3d\Архангельск_Смольный Буян_07_03_18.dwg"
If IO.
File.
Exists(PutchDWG
) = True Then Dim AttchDrawing As Project.AttachedDrawing = activeProject.DrawingSet.AttachDrawing(PutchDWG)
AttchDrawing.Activate()
'AttchDrawing.Preview()
Dim qryModel As QueryModel = activeProject.CreateQuery()
qryModel.Clear()
Dim locationCondition As Query.LocationCondition = New Query.LocationCondition
Dim qryCondition As LocationCondition = New LocationCondition()
locationCondition.Boundary = PolylineBoundary.Create()
Dim pCol As PolylineVertexCollection = New PolylineVertexCollection
Dim acSSPrompt As PromptSelectionResult = acDoc.Editor.GetSelection()
If acSSPrompt.Status = PromptStatus.OK Then
Dim acSSet As SelectionSet = acSSPrompt.Value
For Each acSSObj As SelectedObject In acSSet
If Not IsDBNull(acSSObj) Then
Dim acEnt As Autodesk.AutoCAD.DatabaseServices.Entity = acTrans.GetObject(acSSObj.ObjectId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
If Not IsDBNull(acEnt) Then
If TypeOf acEnt Is Polyline Then
Dim Pline As Polyline = acEnt
For i As Integer = 0 To Pline.NumberOfVertices - 1
Dim pline3d As Point3d = Pline.GetPoint3dAt(0)
Dim pvt As PolylineVertex
pvt.Vertex = pline3d
pCol.Add(pvt)
Next i
End If
End If
End If
Next
End If
Dim PlineBdry As PolylineBoundary = New PolylineBoundary(pCol, Vector3d.ZAxis, True)
qryCondition.Boundary = PlineBdry
Dim qryBranch As New QueryBranch(JoinOperator.OperatorAnd)
qryBranch.AppendOperand(qryCondition)
qryModel.Define(qryBranch)
qryModel.Mode = QueryType.QueryDraw
qryModel.Run()
End If
acTrans.Commit()
End Using
End Sub