Reg. SelectOnScreen for TEXT using C#.NET

Reg. SelectOnScreen for TEXT using C#.NET

Anonymous
Not applicable
1,187 Views
3 Replies
Message 1 of 4

Reg. SelectOnScreen for TEXT using C#.NET

Anonymous
Not applicable

Hi Everyone,

 

C#.NET

 

I want to use select on screen method with Filter type only for "TEXT".

 

Mean I want to select only TEXT from the Selection set so can any one tell me how it can be possible ?

 

I am not able to write the statement for the Filter Type.

 

Request you to post the statement in C#.NET if possible.

0 Likes
1,188 Views
3 Replies
Replies (3)
Message 2 of 4

norman.yuan
Mentor
Mentor

This also replies to your other post.

 

Since you are using .NET language, you should use AutoCAD's .NET API, instead of COM API as your other post shows.

 

You use Editor.GetSelection() or Editor.SelectAll()/SelectcXXXX(), depending on whether you want user to select manually, or you want AutoCAD to do the selection for you.

 

You define selection filter to only filter out TEXT entity this way:

 

TypedValue[] vals=new TypedValue[]{new TypedValue((int)DxfCode.Start,"TEXT")};

PromptSelectionResult res=Application.DocumandManager.MdiDocument.Editor.GetSelection(new SelectionFilter(vals));

if (res.Status==PromptStatus.OK)

{

      ObjectId[] txtIds=res.Value.GetObjectIds();

      //Do something with the select ObjectIds, each of them is guranteed to be ObjectId of a Text entity

}

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thanks for the reply...Actually I was forgot to mentioned that I want that TEXT selection using COM API using C# not .NET API.

 

So if possible can you suggest me how to do it using COM PAI using C# or VB ?


Every time I am getting the same error that Invalid Argument in Filter Data Type ?

0 Likes
Message 4 of 4

lamminhhy9999
Observer
Observer

 I faced this problem recently and found the solution. leave it here for those who come later.

Actually FilterType and FilterData is list object.

//add a selection
AcadSelectionSet select = ThisDrawing.SelectionSets.Add("ss2");

Int16[] FilterType = new Int16[1];
object[] FilterData = new object[1];

FilterType[0] = 0;
FilterData[0] = "Text";

select.SelectOnScreen(FilterType, FilterData);

 

detail about filter https://documentation.help/AutoCAD-ActiveX-AAG/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6c16.htm