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

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #15 on: June 13, 2007, 01:11:14 AM »
Something like this perhaps:

Code: [Select]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedSSSetFirst")]
private static extern int acedSSetFirst(long[] pset, long[] unused);


[CommandMethod("SetFirstTest", CommandFlags.UsePickSet | CommandFlags.Redraw | CommandFlags.Modal)]
static public void SetFirstTestCommand( ) {
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;

try {

PromptSelectionResult prs = ed.SelectImplied();
if(prs.Status != PromptStatus.OK)
return;

SelectionSet ss = prs.Value;
ed.WriteMessage("\nNumber of selected objects: {0}", ss.Count);

acedSSetFirst(null, null);

} catch(System.Exception ex) {
ed.WriteMessage(ex.Message);
}
}


Completely untested of course :)

Cheers,
Glenn.

Paul Richardson

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #16 on: June 13, 2007, 08:34:52 AM »
Something like this perhaps:

Code: [Select]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedSSSetFirst")]
private static extern int acedSSetFirst(long[] pset, long[] unused);


[CommandMethod("SetFirstTest", CommandFlags.UsePickSet | CommandFlags.Redraw | CommandFlags.Modal)]
static public void SetFirstTestCommand( ) {
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;

try {

PromptSelectionResult prs = ed.SelectImplied();
if(prs.Status != PromptStatus.OK)
return;

SelectionSet ss = prs.Value;
ed.WriteMessage("\nNumber of selected objects: {0}", ss.Count);

acedSSetFirst(null, null);

} catch(System.Exception ex) {
ed.WriteMessage(ex.Message);
}
}


Completely untested of course :)

Cheers,
Glenn.

Glenn, Do you know why most of the names are mangled but some not?
Thanks.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: DeSelect current selectin set from Tool Palette
« Reply #17 on: June 13, 2007, 08:58:04 AM »
I know you asked Glenn, but… :-P
The function was probably exported as a global function for ARX, but not yet wrapped for .NET

Glenn R

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #18 on: June 13, 2007, 09:07:58 AM »
It has to do with the c++ compiler, function exports and name collisions wrt the vtable AFAIK.

Cheers,
Glenn.

Paul Richardson

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #19 on: June 13, 2007, 09:40:04 AM »
I know you asked Glenn, but… :-P
The function was probably exported as a global function for ARX, but not yet wrapped for .NET


Well... I meant anyone with the answer...~) Thanks...

Paul Richardson

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #20 on: June 13, 2007, 09:41:33 AM »
It has to do with the c++ compiler, function exports and name collisions wrt the vtable AFAIK.

Cheers,
Glenn.

Danka... Just curious.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: DeSelect current selectin set from Tool Palette
« Reply #21 on: June 13, 2007, 11:19:51 AM »
For now you could try this - until you master P/Invoke...:)
This doesn't look like it will happen anytime soon.  :-)  I didn't understand the article on first read, so I have to reread it when I have more time to comprehend it.

object o = AcadApp.GetSystemVariable("Pickfirst");
 AcadApp.SetSystemVariable("Pickfirst", o);
This worked nicely.  I will post the full code in the other thread as that is where it is posted now.

Thanks Paul!
Tim

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

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: DeSelect current selectin set from Tool Palette
« Reply #22 on: June 13, 2007, 11:33:47 AM »
Something like this perhaps:

Code: [Select]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedSSSetFirst")]
private static extern int acedSSetFirst(long[] pset, long[] unused);


[CommandMethod("SetFirstTest", CommandFlags.UsePickSet | CommandFlags.Redraw | CommandFlags.Modal)]
static public void SetFirstTestCommand( ) {
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;

try {

PromptSelectionResult prs = ed.SelectImplied();
if(prs.Status != PromptStatus.OK)
return;

SelectionSet ss = prs.Value;
ed.WriteMessage("\nNumber of selected objects: {0}", ss.Count);

acedSSetFirst(null, null);

} catch(System.Exception ex) {
ed.WriteMessage(ex.Message);
}
}


Completely untested of course :)

Cheers,
Glenn.
Thanks for the example Glenn.  I will try and understand it when I have more time later today.

Edit: May take more time than I originally thought. =D  Need to study up on DllImport.
« Last Edit: June 13, 2007, 05:43:27 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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: DeSelect current selectin set from Tool Palette
« Reply #23 on: June 13, 2007, 06:56:31 PM »
Thanks Glenn that worked with one small correction.  The function name is 'SSSetFirst', with three 's'.

I have the program 'depends', and I see the call to 'SSSetFirst' within there, but the entry point is a number.  How do I know which one to use (for future situations)?
Tim

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

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: DeSelect current selectin set from Tool Palette
« Reply #24 on: June 13, 2007, 07:11:33 PM »
Tim,

The function name was correct in my code (look at the entrypoint)...I just dropped an 'S' in my alias of it, which doesn't matter (you could it anything you want).

I use "Dumpbin /E" on the file and redirect it's output to a text file...that will give you all the names.

Glenn.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: DeSelect current selectin set from Tool Palette
« Reply #25 on: June 13, 2007, 07:22:38 PM »
Tim,

The function name was correct in my code (look at the entrypoint)...I just dropped an 'S' in my alias of it, which doesn't matter (you could it anything you want).
I thought I looked there first.  Must have thought you named them all the same.  :wink:

I use "Dumpbin /E" on the file and redirect it's output to a text file...that will give you all the names.

Glenn.
I think that is how Kean said to do it on his blog (nope, but something like this method).  I was hoping there would be an easier way.

Thanks again.
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 #26 on: June 13, 2007, 10:11:58 PM »
Tim,

The function name was correct in my code (look at the entrypoint)...I just dropped an 'S' in my alias of it, which doesn't matter (you could it anything you want).
I thought I looked there first.  Must have thought you named them all the same.  :wink:

I use "Dumpbin /E" on the file and redirect it's output to a text file...that will give you all the names.

Glenn.
I think that is how Kean said to do it on his blog (nope, but something like this method).  I was hoping there would be an easier way.

Thanks again.
To use Fenton's method save the batch as findfile.bat (or whatever you like) to your acad root. Using VS comamnd prompt call as such - findfile.bat functionname If you want to write to a text file use the redirection operator as stated findfile.bat functionname > text.txt. This is slow so be patient...

Edit: Browse (cd) to the acad root in the command line tool before running.
« Last Edit: June 13, 2007, 10:25:00 PM by Paul Richardson »