TheSwamp
Code Red => .NET => Topic started by: HD on September 06, 2008, 10:12:29 PM
-
The button control event code below is work in progress. What is happenning is after returning to my main form, the "Insertion Point" prompt remains as the AutoCAD command-line prompt.
Am I doing something wrong or is there some way to clear the command-line prompt prior to returning to my main form?
Just for the heck of it, I placed the code, minus a couple of statements, into a CommandMethod and it works fine.
private void btnInsertion_Click(object sender, EventArgs e)
{
Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor;
this.Hide();
PromptPointOptions options =
new PromptPointOptions("Insertion Point");
PromptPointResult result = ed.GetPoint(options);
if (result.Status != PromptStatus.OK)
return;
this.Show();
Point3d insertionPoint = result.Value;
}
-
Try knocking out the Hide() and Show() function calls and see what happens...
-
What happens if you simply print "\nCommand: " to the command window using Editor.WriteMessage(), just before your button handler ends?
-
Ah, the Swamp gives better answers than ADN. :-D
-
I have done something like this:
[DllImport("user32.dll")]
public static extern System.IntPtr SetFocus(System.IntPtr hwnd);
// modeless form
private void onClick_InstallDoor(object sender, EventArgs e)
{
str_doorwidth = doorWidths_comboBox.GetItemText(doorWidths_comboBox.Items[doorWidthsIndex]);
str_doorname = doorNames_comboBox.GetItemText(doorNames_comboBox.Items[doorNamesIndex]);
str_doortype = doorTypes_comboBox.GetItemText(doorTypes_comboBox.Items[doorTypesIndex]);
str_doorframe = doorFrames_comboBox.GetItemText(doorFrames_comboBox.Items[doorFramesIndex]);
str_doorposition = doorWallPositions_comboBox.GetItemText(doorWallPositions_comboBox.Items[doorWallPositionsIndex]);
str_distanceCorner = editDistanceCorner.Text;
double d_distCorner = Converter.StringToDistance(str_distanceCorner, DistanceUnitFormat.Architectural);
editDistanceCorner.Text = Converter.DistanceToString(d_distCorner, DistanceUnitFormat.Architectural, -1);
try
{
// hide the dialog while doing the installation of doors
Visible = false;
doorInstaller(); // call the function
}
catch (System.Exception ex)
{
MessageBox.Show("Error: " + ex.Message); //in case there is an error, show a message
}
finally
{
Visible = true;
SetFocus(Autodesk.AutoCAD.ApplicationServices.Application.MainWindow.Handle);
}
}
// where the called function is something like:
public static void doorInstaller()
{
string block_dwg = "90 degrees swing"; //default
switch (doorNamesIndex)
{
case 0:
block_dwg = "90 degrees swing";
break;
case 1:
block_dwg = "45 degrees swing";
break;
case 2:
block_dwg = "30 degrees swing";
break;
case 3:
block_dwg = "15 degrees swing";
break;
case 4:
block_dwg = "180 degrees swing";
break;
case 5:
block_dwg = "Pair 90 degrees swing";
break;
case 6:
block_dwg = "Pair 90 degrees double egress";
break;
case 7:
block_dwg = "Sliding";
break;
case 8:
block_dwg = "Pocket";
break;
case 9:
block_dwg = "Folding";
break;
case 10:
block_dwg = "Rolling";
break;
}
Database db = HostApplicationServices.WorkingDatabase;
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
while (true)
{
PromptEntityResult res = ed.GetEntity("\nSelect hinge position: "); //("\n<Enter & back to dialog>/Select hinge position: ")
if (res.Status != PromptStatus.OK)
{
//SetFocus(Autodesk.AutoCAD.ApplicationServices.Application.MainWindow.Handle);
//acedPostCommand("");
//acedPostCommand("\003" + "\003" + "\003");
return;
}
using (DocumentLock doclock = ed.Document.LockDocument())
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
// [color=blue]more mojo..... salsa, guacamole, enchiladas, quesadillas..... goes here[/color]
tr.Commit();
}//transaction
}//docklock
}//while
}
-
** yawn **
PostCommandPrompt (http://www.theswamp.org/index.php?topic=24669.msg297340#msg297340)
-
** yawn **
PostCommandPrompt (http://www.theswamp.org/index.php?topic=24669.msg297340#msg297340)
Are you trying to say "Use Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt()"?
If so, what's wrong with just saying it? Is the commentary ("** yawn**") really necessary?
-
** yawn **
PostCommandPrompt (http://www.theswamp.org/index.php?topic=24669.msg297340#msg297340)
Are you trying to say "Use Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt()"?
Yes.
]
If so, what's wrong with just saying it? Is the commentary ("** yawn**") really necessary?
Considering it was 6:45AM or so in the morning, my eyes were barely open and I knew you'd bite - yes :-D
-
If so, what's wrong with just saying it? Is the commentary ("** yawn**") really necessary?
Considering it was 6:45AM or so in the morning, my eyes were barely open and I knew you'd bite - yes :-D
<insert politically-incorrect comment here> :evil: