.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with interaction SendStringToExecute and SetImpliedSelection

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
mario.rosenbohm
2485 Views, 12 Replies

Problem with interaction SendStringToExecute and SetImpliedSelection

Hallo,

 

i have an problem with interaction between SendStringToExecute and SetImpliedSelection.

 

In following example work the SetImpliedSelection fine without the SendStringToExecute,

but with the SendStringToExecute do SetImpliedSelection nothing.

Why??

 

Code:

        [CommandMethod("-SELTEST", CommandFlags.Transparent | CommandFlags.UsePickSet | CommandFlags.Redraw | CommandFlags.Modal)]
        public void SELTEST()
        {
            Autodesk.AutoCAD.EditorInput.Editor acEditor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.
                                                           MdiActiveDocument.Editor;
            Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection acObjectIdCollection;
            if (acEditor.SelectImplied().Value != null)
            {
                Autodesk.AutoCAD.EditorInput.PromptSelectionResult acPromptSelectionResult = acEditor.SelectImplied();                
                if (acPromptSelectionResult.Status == Autodesk.AutoCAD.EditorInput.PromptStatus.OK)
                    acObjectIdCollection = new Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection(acPromptSelectionResult.Value.GetObjectIds());
                else
                    acObjectIdCollection = new Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection();
                
                // 2 Elements remove from selection for Check                              
                acObjectIdCollection.RemoveAt(0);
                acObjectIdCollection.RemoveAt(0);
                
                // ToArray
                Autodesk.AutoCAD.DatabaseServices.ObjectId[] oIDArray = new Autodesk.AutoCAD.DatabaseServices.ObjectId[acObjectIdCollection.Count];
                acObjectIdCollection.CopyTo(oIDArray,0);

                // SendCommand (without this sendcommand work the SetImpliedSelection fine)
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute("_zoom _a ", false, false, false);

                //Set SelectionSet
                acEditor.SetImpliedSelection(oIDArray); // don't work
            }
        }

 

 regards Mario

12 REPLIES 12
Message 2 of 13

Actually, the SetImpliedSelection Is working just fine.  SendStringToExecute is Asynchronous, so your zoom command runs after the SetImpliedSelection, and clears the selection.

Dave O.                                                                  Sig-Logos32.png
Message 3 of 13

Instead of using SendStringToExecute("_ZOOM _A "); you can use ZoomExtents (or ZoomAll):

public static void ZoomExtents()
{
   object acad = Application.AcadApplication;
   acad.GetType().InvokeMember("ZoomExtents", BindingFlags.InvokeMethod, null, acad, null);
}
public static void ZoomAll() { object acad = Application.AcadApplication; acad.GetType().InvokeMember("ZoomAll", BindingFlags.InvokeMethod, null, acad, null); }

 which can be done synchronously with your's code.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 4 of 13

Thanks Alexander.  I was going to suggest using a graphics system manager to manipulate the view, but it would require that he calculate the extents, which would obviously add a lot of code.  I didn't think about invoking a COM call.

Dave O.                                                                  Sig-Logos32.png
Message 5 of 13

Hallo,

 

for your notes, but the problem is not the "zoom" command. The example code is only a quick and dirty example.

 

In the Application i select the entities or use the pre-selection and take a user input for "new Elevation"

after this i calulate a new ucs and set the editor.currentucs (or smiliar, just i have no autocad).

Now i calling the "_plan  " command to view planar to ucs, '(load "...")' the flatten.lsp with SendCommand.

Then i would like to set the "SetImpliedSelection" with the Objectidcollection from begin of the app and

lastly i calling the "flatten" command. (the origin flatten.lsp i have modify to complete silent)

 

On debug is set the editor.ImpliedSelection okay but on flatten comes to nothing.

I think ist a effect of the asynchronous for SendStringToExecute.

There is a synchronous variant of SendStringToExecute?

 

@Alexander:

On next Monday i test the : acad.GetType().InvokeMember  for my Application.

 

until then a nice weekend.

 

regards Mario

Message 6 of 13


@mario.rosenbohm wrote:

There is a synchronous variant of SendStringToExecute?


http://adndevblog.typepad.com/autocad/2012/04/synchronously-send-and-wait-for-commands-in-autocad-us...

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 7 of 13
_gile
in reply to: Alexander.Rivilis

Hi,

 

You can wrap the P/Invoked acedCmd in an helper 'Command' method. See here:

http://www.theswamp.org/index.php?topic=31886.msg460020#msg460020

 

Then use it as the LISP command function:

 

Command("_.circle", Point3d.Origin, 10.0);

 

Command("_.move", selSet, Point3d.Origin, new Point3d(10.0, 20.0, 0.0));



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 8 of 13

Hello Alexander and _gile

 

the examples of "send synchronously commands" works fine.

 

But now i have one problem by send command '(load "C:/test.lsp")'.

AutoCAD response "LISP command not available"!?

How can i load the lsp-file?

 

When i load the lisp-file on appload automatically then don't find AutoCAD

the lispfunction, response "unknown command". But when i input the same

command in the AutoCAD-Commandline then works the command !?

 

regards Mario

Message 9 of 13

(load...) is not a command.  The acedCmd() method only accepts commands and the input they request..

 

To execute LISP you could use acedEvaluateLisp() or acedInvoke() via P/Invoke.

Message 10 of 13

Tony T.

Are you the Tony T that is all over these boards and metioned in Jerry Winters book?

http://www.designprosoftware.co.uk/
Message 11 of 13

... i give up ...

 

Now i have test all variants of send lisp-Command. No variant works for (load "abc.lsp").

And no synchron commandcalling-variant can call a lisp-exported command.

 

My Solution:

I load the lisp-file over "Appload" and call the lisp-exported function as lasted in my app over "SendStringToExecute".

This works.

Message 12 of 13

i have found in TheSwamp 

 

When .net function set the "CommandFlags.Session" then works the

..

((Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication).ActiveDocument.SendCommand(commandstring);

..

Synchronously. And does what i want.

 

regards ... over and out ...

Mario

Message 13 of 13
haw
Enthusiast
in reply to: mario.rosenbohm

Made my day! Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost