1. Background:
In order to get user input for a Window's two corner points, or get a
circles center point and its radius, I created two DrawJig as my generic CAD
methods used in multiple .NET projects.
The DrawJig was originally created in Acad2006 and they work as expected.
However, the Jig thing is one of the broken compatibility in Acad17.x
(2007,08 and coming 09). That is, in Acad2006, you use JigPromptOptions to
define how Jig prompts user's drag, in Acad2007 (and later),
JigPromptOptions becomes abstract class and you have to use one of the
derived class (JigPromptPointOptions, JigPromptDistanceOptions...). So, I
have to rewrite the code in order for my DrawJig to work in Acad2007. The
rewriting is easy and the code works, well, in all other cases (called from
command line or from a dialog box), but not very well when called from
PaletteSet. To be more accurate, for the purpose of acquiring user input, it
works, but the visual effect are so bad (when called from PaletteSet) that
you hardly see the dragged Window or Circle.
The problem is it only occurs when you use the DrawJig from PaletteSet!
2. Attached:
Attached are an entire VS2005 solution (in C#) of the testing project,
including
The main class: JigTestCommands
A DrawJig class: DrawJig07
A simple Win form to show as DialogBox
A simple Windows User Control to be added into PaletteSet
3. Test and reproduce the situation I described:
The project has been compiled. You can start Acad and NETLoad the
"DrawJig07.dll" directly from "...\bin\debug\" folder. Of you can start the
solution with VS2005, examine the code before you run it.
You can call 4 commands from command line for the test:
a. GetWindow - start GetWindowJig from command line. It works as expected;
b. GetCircle - start GetCircleJig from command line. Works OK;
c. JigForm - Shows a dialogbox with two buttons, which let you pick Window
or Circle in Acad. Works as expected. One additional explanation. I placed
this.Hide() and this.Show() around DrawJig calls. You do not have to do
this. AutoCAD hide the dialogbox automatically when your code need to
interact with Editor. However, the screen flickers with the dialogbox
splashes quickly. I found use this.Hide() and this.Show() prevent this
unpleasant effect.
d. JigPatellte - Shows a PaletteSet hosting a Windows User Control with two
buttons, which call my DrawJig. After the PaletteSet shows, make sure to
undock it (floating Window), because I toggle the PaletteSet.Visible
property during the DrawJig call. Now, click one of the buttons to call
GetWimdowJig or GetCircelJig. You almost could not see the dragged window or
circle. However, the DrawJig still works in the regard of getting user input
(for a window/circle). The other thing to watch is during the drag, Acad is
very busy, even you hold the mouse still. You can observe this by open
Windows' task manager (you may want to set it "Always on top", if you only
has one screen): Acad consuming a lot of CPU percentage during dragging,
even
the mouse is not moving. This heavy CPU usage does not appear when calling
the DrawJig with other three commands.
4. Questions:
Does anyone notice this?
Or can anyone reproduce this? I have tried this with three different
computers/OSs: Win VISTA+AcadMap2007, WinServer2003SP2+AcadMap2007 and Win
XP Pro SP2+Acad2007 (the Video cards are all different), so I am pretty sure
it is not causes by hardware/OS.
I do not have Acad2008 available, can someone test it on Acad2008?
5. The DrawJig code
Anyone, who is interested in the DrawJog07 code, is free to use/copy the
code in all sorts of Acad development, as long as it helps. Giving credit in
you code when use it is preferred, but not required