Is it possible to make ObjectId as SelectionFilter in the selection set?

Is it possible to make ObjectId as SelectionFilter in the selection set?

iamhermit
Participant Participant
534 Views
5 Replies
Message 1 of 6

Is it possible to make ObjectId as SelectionFilter in the selection set?

iamhermit
Participant
Participant

I didn't find the ObjectId key in the DxfCode.

As to why, because SelectAll would be select itself in WorldDraw(), leads to a catastrophic bug when copying, so I needed to exclude its own id from the selection.

0 Likes
535 Views
5 Replies
Replies (5)
Message 2 of 6

norman.yuan
Mentor
Mentor

I am confused: the purpose of using Editor.SelectXXXX (with or without filter) is to get a set of entities (referred by their ObjectIds). If you already know the ObjectId or ObjectIds, why do you need to use it/them as filter to get them back from calling Editor.SelectXXXX()?

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 6

iamhermit
Participant
Participant

Because I want to select other same type(class) entitys in the worlddraw event, but not to select itself. Once selected by the selection set, it seems to trigger the bug, regardless of how the selection result is handled later.

0 Likes
Message 4 of 6

norman.yuan
Mentor
Mentor

So, you want to select  entities with "type" filter" but exclude one(s) with given ObjectId(s). You can handle Editor.SelectionAdded event to see if the added entities include the said ObjectId(s) and remove it/them if necessary. Or you can simply check the selection result, after the selection is done and before you pass the selection set for next execution, and removed the tagetted ObjectId(s). I'd go with latter, it is simple and straightforward:

 

if (selResult.Status == PromptStatus.OK)

{

  var ids=selResult.Value.GetObjectIds().ToList();

  if (ids.Contains(exclusiveId))

  {

    ids.Remove(excusiveId);

  }

  DoSomeThing(ids);

}

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 6

iamhermit
Participant
Participant

I mentioned that the bug will be triggered as soon as itself is selected, so the second option seems not applicable.

As for SelectionAdded event, it is a new idea, I will try to verify if it can avoid the problem, and reply to you when the test results are available, thank you!

0 Likes
Message 6 of 6

norman.yuan
Mentor
Mentor

OK, while you did not say how your WorldDraw() is called (possibly an override of "automatic execution", such as overrule...), it seems to me it is called automatically by AutoCAD whenever something is selected. In this case, I am not sure SelectionAdded event would help. In this case, you should do something inside your overridden WorldDraw() to exclude certain ObjectId (of course it should be in application/global scope) before the WorldDraw() runs into it (say, before you call base.WorldDraw()).

Norman Yuan

Drive CAD With Code

EESignature

0 Likes