All,
looking to revisit selection set to write block reference coordinates to a text file, x,y,z, csv. print to dialog for testing is perfect.
I don't understand how to get the x,y,z positions for the block in the selection set. It appears the ss does not contain the insertion point of the blocks, I can get the layer and block name but I don't know where or how the get the insertion points. what do I need to access to pull those values out.
Do I get the insertion points from the objectid?
sample I was using
<CommandMethod("filterblocks10")> _
Public Sub FilterBlocks10()
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor()
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim acaddoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim opts As PromptEntityOptions = New PromptEntityOptions("" & vbLf & "Select One Target Block, For Selection Set:")
opts.SetRejectMessage("No Target Block Selected.")
opts.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.BlockReference), True)
Dim per As PromptEntityResult = ed.GetEntity(opts)
If (per.Status <> PromptStatus.OK) Then
Return
End If
Dim oSset As SelectionSet = Nothing
Dim mytrans As Transaction = db.TransactionManager.StartTransaction
Dim br As Autodesk.AutoCAD.DatabaseServices.BlockReference = CType(mytrans.GetObject(per.ObjectId, OpenMode.ForRead), Autodesk.AutoCAD.DatabaseServices.BlockReference)
Dim acBlockTable As BlockTable
acBlockTable = mytrans.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim acBlockTableRec As BlockTableRecord
acBlockTableRec = mytrans.GetObject(acBlockTable(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim filterlist() As TypedValue = New TypedValue((3) - 1) {}
filterlist(0) = New TypedValue(0, "INSERT")
filterlist(1) = New TypedValue(2, br.Name)
filterlist(2) = New TypedValue(8, br.Layer)
Dim filter As SelectionFilter = New SelectionFilter(filterlist)
Dim psr As PromptSelectionResult = ed.SelectAll(New SelectionFilter(filterlist))
ed.SetImpliedSelection(psr.Value)
ed.WriteMessage("" & vbLf & "Number of selected objects: {0}", psr.Value.Count)
'show dialog with filter results, insert, block name and layer name. need block position.x,block position.y,block position.z
Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Number of objects selected: " & psr.Value.Count.ToString())
Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Block Name is: " & br.Name.ToString())
Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Block Is on Layer: " & br.Layer.ToString())
'Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("x insertion point : " & br.pointion.x.ToString())
'Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("y insertion point : " & br.pointion.y.ToString())
'Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("z insertion point : " & br.pointion.z.ToString())
mytrans.Commit()
End Sub