Message 1 of 7
Getting co-ordinates from selection set entities

Not applicable
05-28-2005
02:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I've been trying to get the co-ordinates of circles in a selection set as
created in the ObjectArx demo code. I have tried every method O can think of
but there doesn't seem to be a method of obtaining the value of the centres.
Code from the demo posted below with notes to indicate what I am trying to
do. I may be missing something obvious here as it should be a simple
process.
Thanks for any ideas.
Simon
Public Sub ssGetFilter()
'Setup
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
'Declare our filter entries this way.
'We build them the same way in ObjectARX.
'DxfCode.Start (equal to 0) - This is for 'Entity Name'
'DxfCode.Color is for ACI color - 1 = Red
Dim values() As TypedValue = { _
New TypedValue(DxfCode.Start, "CIRCLE"), _
New TypedValue(DxfCode.Color, 1) _
}
Dim sfilter As New SelectionFilter(values) ' Create the filter using our
values...
'Set the selection options
Dim SelOpts As New PromptSelectionOptions()
SelOpts.MessageForAdding = "Select Red Circles:"
SelOpts.AllowDuplicates = True
'Make the selection:
Dim res As PromptSelectionResult = ed.GetSelection(SelOpts, sfilter)
If Not res.Status = PromptStatus.OK Then Return
Dim SS As Autodesk.AutoCAD.EditorInput.SelectionSet = res.Value
Dim idarray As ObjectId() = SS.GetObjectIds()
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager =
db.TransactionManager
'start a transaction
Dim myT As Transaction = tm.StartTransaction()
Try
Dim id As ObjectId
For Each id In idarray
Dim entity As Entity = tm.GetObject(id, OpenMode.ForRead, True)
ed.WriteMessage((ControlChars.Lf + "You selected: " +
entity.GetType().FullName))
' ********************************************Put something here along the
lines of entity.value or id.value I can't find where the co-ords a re stored
Next id
Finally
myT.Dispose()
End Try
End Sub
I've been trying to get the co-ordinates of circles in a selection set as
created in the ObjectArx demo code. I have tried every method O can think of
but there doesn't seem to be a method of obtaining the value of the centres.
Code from the demo posted below with notes to indicate what I am trying to
do. I may be missing something obvious here as it should be a simple
process.
Thanks for any ideas.
Simon
Public Sub ssGetFilter()
'Setup
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
'Declare our filter entries this way.
'We build them the same way in ObjectARX.
'DxfCode.Start (equal to 0) - This is for 'Entity Name'
'DxfCode.Color is for ACI color - 1 = Red
Dim values() As TypedValue = { _
New TypedValue(DxfCode.Start, "CIRCLE"), _
New TypedValue(DxfCode.Color, 1) _
}
Dim sfilter As New SelectionFilter(values) ' Create the filter using our
values...
'Set the selection options
Dim SelOpts As New PromptSelectionOptions()
SelOpts.MessageForAdding = "Select Red Circles:"
SelOpts.AllowDuplicates = True
'Make the selection:
Dim res As PromptSelectionResult = ed.GetSelection(SelOpts, sfilter)
If Not res.Status = PromptStatus.OK Then Return
Dim SS As Autodesk.AutoCAD.EditorInput.SelectionSet = res.Value
Dim idarray As ObjectId() = SS.GetObjectIds()
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager =
db.TransactionManager
'start a transaction
Dim myT As Transaction = tm.StartTransaction()
Try
Dim id As ObjectId
For Each id In idarray
Dim entity As Entity = tm.GetObject(id, OpenMode.ForRead, True)
ed.WriteMessage((ControlChars.Lf + "You selected: " +
entity.GetType().FullName))
' ********************************************Put something here along the
lines of entity.value or id.value I can't find where the co-ords a re stored
Next id
Finally
myT.Dispose()
End Try
End Sub