So currently I'm trying to select objects that I am adding to the drawing. I want to add these to a selection set and then access that selection set through Interop. There is very little on the internet that I could find on doing something like this, but the command that I though might work, gives me an error,
acSSet2 = SelectionSet.FromObjectIds(ids)
Here is a very summarized version of my code:
'Add the mirrored items to a new selection set
Dim acSSet2 As SelectionSet
Dim ids(15) As ObjectId
Dim int As Integer = 0
'' Step through the objects in the selection set
For Each acSSObj As SelectedObject In acSSet
' Add the new object to the block table record and the transaction
acBlkTblRec.AppendEntity(acEnt2)
acTrans.AddNewlyCreatedDBObject(acEnt2, True)
ids(int) = (acEnt2.ObjectId)
int = int + 1
Next
acSSet2 = SelectionSet.FromObjectIds(ids)
acadDoc = AcadApp.ActiveDocument
ssetObj = AcadApp.ActiveDocument.ActiveSelectionSet
acadDoc.Export(System.IO.Path.GetFullPath(acCurDb.Filename), "wmf", CType(acSSet2, AcadSelectionSet))
I was hoping that when I added the items to acSSet2, AcadApp.ActiveDocument.ActiveSelectionSet would catch it and use it. But that didn't work so I added,
CType(acSSet2, AcadSelectionSet)
but then it gave me this error
************** Exception Text **************
System.InvalidCastException: Unable to cast object of type 'Autodesk.AutoCAD.EditorInput.SelectionSetDelayMarshalled' to type 'Autodesk.AutoCAD.Interop.AcadSelectionSet'.
at TestSelectingFiltering.TestSelecting.MyCommands.FilterBlueCircleOnLayer0()
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()
Any help would be great, this has been driving me crazy!
Thanks!