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

Synchronous Command Troubles

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
658 Views, 3 Replies

Synchronous Command Troubles

In an application I'm working on, I had two CommandMethods.

 

One was a "Find" style function, where a user would enter some data, some processing was completed, relevant block or other Object data was seleted (I'm using Editor.SetImpliedSelection(ObjectId)), and then I would run

SendStringToExecute("ZOOM\nOBJECT\n", false, false, false);

The end result was a dynamic zoom in on the objects in question, which our users like.

 

The second command launches a dialog box. It's got a CommandFlags.UsePickSet with Editor.SelectImplied(), so the user can either select relevant objects and run the command, or run then select, and they get the dialog either way.

 

I now need to make a combined command that zooms in, and launches the dialog in one go. I'm running into all sorts of issues with this.

  1. If I SendStringToExecute the Zoom, and then the Dialog, the dialog completes faster. Once exiting the dialog, the zoom runs. So they are out of order.
  2. I tried launching the actual function instead of the CommandMethod, such as doThis(). Again, out of order.
  3. I've tried following some examples on Synchronous commands (Caddzone, someone named Tony, RunCommand, others). Doing these seem to kill the dynamic zoom, which I want to see. Immediately after the zoom, I would get errors in the command window about being unable to run transparent commands (I couldn't even exit AutoCAD at this point, because clicking the X to 'quit' would return this error). I also lack experience with ResultBuffers and using COM Interop, so I may just be doing it wrong.
  4. The order will be maintained if I go the inefficient route and throw in a Thread.Sleep(1000) after the Zoom command, so it has time to complete. This successfully puts the commands in the right order, BUT, when the dialog's CommandMethod is run, it doesn't catch the selected Objects/entities from Editor.SetImpliedSelection, and defaults to waiting for user input again. I've debugged this, and found that as soon as the SendStringToExecute(CommandMethodForMyDialog) is run, it's as though a new instance of the editor is created and using Editor.SelectImplied() fails.
  5. If I use Thread.Sleep and then call the dialog's function, and pass in the data as a parameter instead of SendStringToExecute and trying to UsePickSet, the program just hangs for the sleep time, launches the dialog, and then does the Zoom. So order is lost again.

 

The end result I want is that the user supplies their original input, dynamic zoom takes place, and then the dialog pops up. I'm not sure how to make this happen, just like that, in that order.

3 REPLIES 3
Message 2 of 4
Jeff_M
in reply to: Anonymous

The best solution, imho, is to not use the SendStringToExecute. Do the zoom in your code and don't rely on native command calls. Here are some examples to get you going:

 

http://forums.autodesk.com/t5/NET/Zoom-to-Objects/m-p/2788358#M20933

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 4
Anonymous
in reply to: Jeff_M

I straight-copied those in and gave them each a shot. Hallex's didn't work how I expected, but the others did zoom in on an object correctly. The problem here is that they don't dynamically zoom in on the target object, instead they are instant.

 

That raises the question of if there's a good, programmatic way to dynamically zoom. jboone threw an idea my way in this thread, and I haven't heard of another implementation (yet). If you have any alternative ideas, I'm all ears, before I get to writing my own.

Message 4 of 4
_gile
in reply to: Anonymous

Hi,

 

You can have a look here too:

http://through-the-interface.typepad.com/through_the_interface/2008/06/zooming-to-a-wi.html



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

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