Author Topic: DeSelect current selectin set from Tool Palette  (Read 7502 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5243
DeSelect current selectin set from Tool Palette
« on: June 12, 2007, 02:52:01 PM »
I have code that will make a tool palette, and fill it with combo boxes and put one button on it.  I use the current selection set to populate the tool palette (single block with attributes).  Everything works fine except that I can't figure out how to deselect the objects once the button is pushed.  Any help/comments are appreciated.

Thanks in advance.

Question in reference to here.  Posting new thread because this question may get lost in the other one.

I have seen this method posted on the Adesk Ng, but didn't work for me.
Code: [Select]
PromptSelectionResult psr = Doc.Editor.SelectImplied();
psr = null;
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Paul Richardson

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #1 on: June 12, 2007, 03:07:38 PM »
I have code that will make a tool palette, and fill it with combo boxes and put one button on it.  I use the current selection set to populate the tool palette (single block with attributes).  Everything works fine except that I can't figure out how to deselect the objects once the button is pushed.  Any help/comments are appreciated.

Thanks in advance.

Question in reference to here.  Posting new thread because this question may get lost in the other one.

I have seen this method posted on the Adesk Ng, but didn't work for me.
Code: [Select]
PromptSelectionResult psr = Doc.Editor.SelectImplied();
psr = null;

Tim - I think I'm the one who posted that code... Strange it does work for me. I just tried this on a block
with references and it works here. Maybe another way to do it?

Code: [Select]
Editor ed =
    Autodesk.AutoCAD.ApplicationServices.Application.
        DocumentManager.MdiActiveDocument.Editor;
PromptSelectionResult psr = ed.SelectImplied();
psr = null;


T.Willey

  • Needs a day job
  • Posts: 5243
Re: DeSelect current selectin set from Tool Palette
« Reply #2 on: June 12, 2007, 03:19:43 PM »
That didn't work either Paul.  I think the issue is trying to deselect from the tool palette.  Did you get it to work from a tool palette?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #3 on: June 12, 2007, 03:29:53 PM »
Hey Tim;

How about using: SetImpliedSelection()

ed.SetImpliedSelection(new ObjectId[0]);

T.Willey

  • Needs a day job
  • Posts: 5243
Re: DeSelect current selectin set from Tool Palette
« Reply #4 on: June 12, 2007, 03:37:55 PM »
Hey Tim;

How about using: SetImpliedSelection()

ed.SetImpliedSelection(new ObjectId[0]);
Build error.
Quote
error CS1501: No overload for method 'SelectImplied' takes '1' arguments
c:\Program Files\Autodesk\Acade 2006\acmgd.dll: (Location of symbol related to previous error)
Code: [Select]
Doc.Editor.SelectImplied(new ObjectId[0]);

Man this is frustrating.

Edit:
Now using the correct code.  Man, still get build error.
Quote
error CS0117: 'Autodesk.AutoCAD.EditorInput.Editor' does not contain a definition for 'SetImpliedSelection'

On Acad '06
« Last Edit: June 12, 2007, 03:41:50 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #5 on: June 12, 2007, 03:42:15 PM »
Hey Tim;

How about using: SetImpliedSelection()

ed.SetImpliedSelection(new ObjectId[0]);
Build error.
Quote
error CS1501: No overload for method 'SelectImplied' takes '1' arguments
c:\Program Files\Autodesk\Acade 2006\acmgd.dll: (Location of symbol related to previous error)
Code: [Select]
Doc.Editor.SelectImplied(new ObjectId[0]);

Man this is frustrating.

Count to 10... 9 8 7 6 5 4 3 2 1 0...

I simple posted from memory, don't have my vs open....

LE

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #6 on: June 12, 2007, 03:57:30 PM »
It is working here, as far as I see it...

Code: [Select]
       public static  void onDocBecameCurrent(object sender, DocumentCollectionEventArgs e)
        {
            Document doc = AcadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            ed.SetImpliedSelection(new ObjectId[0]);//clear first any selection
            if (!ps.Visible) return;
            PromptSelectionResult psr = e.Document.Editor.SelectImplied() as PromptSelectionResult;
            //if (psr == null) return;
            SelectionSet ss = psr.Value as SelectionSet;
            if (ss != null && ss.Count > 0) FillInControl(ss.GetObjectIds());
            else if (ps.Count > 0) ps.Remove(0);
        }

Paul Richardson

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #7 on: June 12, 2007, 03:58:31 PM »
That didn't work either Paul.  I think the issue is trying to deselect from the tool palette.  Did you get it to work from a tool palette?

I haven't tried...

T.Willey

  • Needs a day job
  • Posts: 5243
Re: DeSelect current selectin set from Tool Palette
« Reply #8 on: June 12, 2007, 04:02:02 PM »
It is working here, as far as I see it...

Code: [Select]
       public static  void onDocBecameCurrent(object sender, DocumentCollectionEventArgs e)
        {
            Document doc = AcadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            ed.SetImpliedSelection(new ObjectId[0]);//clear first any selection
            if (!ps.Visible) return;
            PromptSelectionResult psr = e.Document.Editor.SelectImplied() as PromptSelectionResult;
            //if (psr == null) return;
            SelectionSet ss = psr.Value as SelectionSet;
            if (ss != null && ss.Count > 0) FillInControl(ss.GetObjectIds());
            else if (ps.Count > 0) ps.Remove(0);
        }
What version are you testing on?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #9 on: June 12, 2007, 04:03:01 PM »
2007

T.Willey

  • Needs a day job
  • Posts: 5243
Re: DeSelect current selectin set from Tool Palette
« Reply #10 on: June 12, 2007, 04:04:07 PM »
2007
Must be new to 2007 because I get a build error when trying it with 2006.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #11 on: June 12, 2007, 04:09:58 PM »
no idea Tim.

this is what I see on the object browser:

LE

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #12 on: June 12, 2007, 04:17:08 PM »
In case is not there, do you know how to use P/Invoke? (because I do not)... that function is a wrapper from the ARX functions of:

acedSSSetFirst()
acedSSFree()

T.Willey

  • Needs a day job
  • Posts: 5243
Re: DeSelect current selectin set from Tool Palette
« Reply #13 on: June 12, 2007, 05:00:07 PM »
In case is not there, do you know how to use P/Invoke? (because I do not)... that function is a wrapper from the ARX functions of:

acedSSSetFirst()
acedSSFree()
If this is the only way in .Net (for '06), then I guess I better learn about P/Invoke.  Thanks for the heads up Luis.  I'll see what I can find.

Edit: Found this link.  Reading it now.
« Last Edit: June 12, 2007, 05:04:03 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Paul Richardson

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #14 on: June 12, 2007, 08:05:55 PM »
In case is not there, do you know how to use P/Invoke? (because I do not)... that function is a wrapper from the ARX functions of:

acedSSSetFirst()
acedSSFree()
If this is the only way in .Net (for '06), then I guess I better learn about P/Invoke.  Thanks for the heads up Luis.  I'll see what I can find.

Edit: Found this link.  Reading it now.

For now you could try this - until you master P/Invoke...:)

 object o = AcadApp.GetSystemVariable("Pickfirst");
 AcadApp.SetSystemVariable("Pickfirst", o);