Hello,
In the code below, I am using a window to select a circle in the drawing. I'm using a window because of the fudge factor in the placement of circles. The problem is, when it gets to the line:
sourceBlockRef = sourceBallObjID.GetObject(DatabaseServices.OpenMode.ForRead)
The program hangs. I'm new to working with selection sets, so if anyone can help me out with this one I'd really appreciate it.
Dim sourceBallPSR As EditorInput.PromptSelectionResult
Dim sourceBallSelectionSet As EditorInput.SelectionSet
Dim sourceBallObjIDs As DatabaseServices.ObjectIdCollection
Dim sourceBallObjID As DatabaseServices.ObjectId
Dim bgaFilter(0) As DatabaseServices.TypedValue
bgaFilter(0) = New DatabaseServices.TypedValue(DatabaseServices.DxfCode.Start, "CIRCLE")
Dim bgaSSFilter As New EditorInput.SelectionFilter(bgaFilter)
' Select the first circle using a window
sourceBallPSR = myEd.SelectWindow(sourceWinPnt1, sourceWinPnt2, bgaSSFilter)
' If a cicle is selected
If Not IsNothing(sourceBallPSR.Value) Then
sourceBallSelectionSet = sourceBallPSR.Value
sourceBallObjIDs = New DatabaseServices.ObjectIdCollection(sourceBallSelectionSet.GetObjectIds)
For Each sourceBallObjID In sourceBallObjIDs
Dim sourceBlockRef As DatabaseServices.BlockReference
sourceBlockRef = sourceBallObjID.GetObject(DatabaseServices.OpenMode.ForRead)
sourceBallCenter = sourceBlockRef.Position
Next
myBT = myDWG.Database.BlockTableId.GetObject(DatabaseServices.OpenMode.ForRead)
myBTR = myBT(DatabaseServices.BlockTableRecord.ModelSpace).GetObject(DatabaseServices.OpenMode.ForWrite)
'Draw the circle
Dim newCircle1 As New DatabaseServices.Circle(sourceBallCenter, New Geometry.Vector3d(0, 0, 1), (ballSize / 4))True)
myBTR.AppendEntity(newCircle1)
myTrans.AddNewlyCreatedDBObject(newCircle1,
sourceBallCount = 1
:
:
:
Thanks,
Mark