Albert,
Thanks for that. I had thought to do that but .ToString doesn't come up in
intellisense so I didn't try it. If you type it in it works fine. Thanks
very much.
Simon
"Albert Szilvasy" wrote in message
news:4862797@discussion.autodesk.com...
The problem is simple: you are trying to cast a Point3d to a String (the
exception thrown actually says that.)
You need to modify this:
------------------
Dim k
k = Circ.Center
ed.WriteMessage((ControlChars.Lf + "CENT " & k))
-----------------
To this:
----------------
Dim k
k = Circ.Center
ed.WriteMessage((ControlChars.Lf + "CENT " & k.ToString()))
-----------
I could've spotted this in first post if I was a bit more versed in VB.
Albert
"Simon" wrote in message
news:4859733@discussion.autodesk.com...
Albert,
Here's the code, much of it is as the sample from the sdk. I thought this
would be simple and it probably is once you know how.
Cheers,
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)
Dim entity As Entity = tm.GetObject(id, OpenMode.ForRead, True)
ed.WriteMessage((ControlChars.Lf + "You selected: " +
entity.GetType().FullName))
If TypeOf entity Is Autodesk.AutoCAD.DatabaseServices.Circle Then
Dim Circ As Autodesk.AutoCAD.DatabaseServices.Circle = entity
Dim k
k = Circ.Center
ed.WriteMessage((ControlChars.Lf + "CENT " & k))
End If
Next id
Finally
myT.Dispose()
End Try
End Sub
"Albert Szilvasy" wrote in message
news:4859720@discussion.autodesk.com...
Can you post a complete example that shows the problem? This is very much
possible and in fact fairly simple to do so I'd like to look at your code to
diagnose the problem.
Albert
"Simon" wrote in message
news:4859602@discussion.autodesk.com...
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