TheSwamp
Code Red => .NET => Topic started by: T.Willey 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. (http://www.theswamp.org/index.php?topic=16861.0) 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.
PromptSelectionResult psr = Doc.Editor.SelectImplied();
psr = null;
-
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. (http://www.theswamp.org/index.php?topic=16861.0) 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.
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?
Editor ed =
Autodesk.AutoCAD.ApplicationServices.Application.
DocumentManager.MdiActiveDocument.Editor;
PromptSelectionResult psr = ed.SelectImplied();
psr = null;
-
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?
-
Hey Tim;
How about using: SetImpliedSelection()
ed.SetImpliedSelection(new ObjectId[0]);
-
Hey Tim;
How about using: SetImpliedSelection()
ed.SetImpliedSelection(new ObjectId[0]);
Build error.
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)
Doc.Editor.SelectImplied(new ObjectId[0]);
Man this is frustrating.
Edit:
Now using the correct code. Man, still get build error.
error CS0117: 'Autodesk.AutoCAD.EditorInput.Editor' does not contain a definition for 'SetImpliedSelection'
On Acad '06
-
Hey Tim;
How about using: SetImpliedSelection()
ed.SetImpliedSelection(new ObjectId[0]);
Build error.
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)
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....
-
It is working here, as far as I see it...
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);
}
-
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...
-
It is working here, as far as I see it...
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?
-
2007
-
2007
Must be new to 2007 because I get a build error when trying it with 2006.
-
no idea Tim.
this is what I see on the object browser:
-
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()
-
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. (http://through-the-interface.typepad.com/through_the_interface/2006/07/calling_objecta.html) Reading it now.
-
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. (http://through-the-interface.typepad.com/through_the_interface/2006/07/calling_objecta.html) Reading it now.
For now you could try this - until you master P/Invoke...:)
object o = AcadApp.GetSystemVariable("Pickfirst");
AcadApp.SetSystemVariable("Pickfirst", o);
-
Something like this perhaps:
[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.
-
Something like this perhaps:
[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.
-
I know you asked Glenn, but… :-P
The function was probably exported as a global function for ARX, but not yet wrapped for .NET
-
It has to do with the c++ compiler, function exports and name collisions wrt the vtable AFAIK.
Cheers,
Glenn.
-
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...
-
It has to do with the c++ compiler, function exports and name collisions wrt the vtable AFAIK.
Cheers,
Glenn.
Danka... Just curious.
-
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!
-
Something like this perhaps:
[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.
-
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,
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.
-
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,
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.