.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

COM Selection Set All Filter Values

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
608 Views, 6 Replies

COM Selection Set All Filter Values

Using C# with the COM object, I'm trying to select all the objects in Paperspace and then wblock them out so I can insert them into a different drawing.

I"m having issues determining how to pass the filter object to AutoCAD from C#

AcadDocument oDocChild = oAcad.Documents.Open(sFileName, false, "");
oDocChild.ActiveSpace = AcActiveSpace.acPaperSpace;
AcadSelectionSet ssPSpace = oDoc.SelectionSets.Add("Paper");
object[] oFilter = new object[0];
object[] oData = new object[0];
ssPSpace.Select(AcSelect.acSelectionSetAll, null, null, oFilter, oData);

I've also tried using null values instead of the object values, but it throws an exception error each time.

I know I can for each through all the objects in modelspace and then add it to my selectset, but wouldn't it be easier just to use a selectionsetall mode?

Thanks in Advance,
Bob
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

Okay,
I found the filter type error.
I changed
object[] oFilter = new object[0];
to
short[] oFilter = new short[0];

This gets me past the first error, but I don't want a filter, but the exception error expects data passed in.

Any suggestions?

Bob
Message 3 of 7
cgay
in reply to: Anonymous

Bob,

Have you tried:
ssPSpace.Select(AcSelect.acSelectionSetAll, null, null, null, null);

yet?
Message 4 of 7
Anonymous
in reply to: Anonymous

Yes.
I've now tried to enter some values in the filter types.

short[] oFilter = {67};
object[] oData = {1};

This is supposed to return all object in paperspace. I've tried using 0 and 1 in the data (modelspace/paperspace), but I do not get any entities selected in my selectionset.

Bob
Message 5 of 7
cgay
in reply to: Anonymous

Sorry Bob, I missed the part in your 1st post where you said it.
Try this:

[code]
String sFileName = "C:\\Drawing1.dwg";

AcadApplication acadApp = (AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application");
acadApp.Visible = true;
AcadDocument oDocChild = acadApp.Documents.Open(sFileName, false, "");
oDocChild.ActiveSpace = Autodesk.AutoCAD.Interop.Common.AcActiveSpace.acPaperSpace;
AcadSelectionSet ssPSpace = oDocChild.SelectionSets.Add("Paper");
short[] oFilter = new short[] {67};
object[] oData = new object[] {"1" };
try
{
ssPSpace.Select(Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetAll,
null, null, oFilter , oData );
}
catch (System.Exception)
{
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(acadApp);
[/code]

Note that "oFilter" is of type short

C
Message 6 of 7
Anonymous
in reply to: Anonymous

AcadSelectionSet ssPSpace = oDoc.SelectionSets.Add("Paper");
short[] oFilter = new short[] { 67 };
object[] oData = new object[] { 1 };
ssPSpace.Select(AcSelect.acSelectionSetAll, null, null, oFilter, oData);

Thanks for the help, but I while 'm not getting any exceptions, I'm still unable to get a result with my selectionset using either the "1" or a 1 in the oData object.
If I write the code in VBA I get over a 132 objects returned.
Any other suggestions?

Bob
Message 7 of 7
cgay
in reply to: Anonymous

Bob,

1.) Did you try the code exactly as I posted it? It did work for me.

2.) Have you thought about VB.NET? It would allow you to call obj.Select(AcSelect.acSelectionSetAll) without requiring the filter.

3.) Use AutoCAD Managed wrappers, ObjectARX. Requires AutoCAD >=2005.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost