- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The code I have works fine functionally and just trying to clean it up, so when others simply hit Enter to run PREVIEW again, it does that instead of the other Command I've invoked w/ Veto().
I am also certain that @ActivistInvestor has written about this before, but I either failed to find it, or Autodesk recently deleted it.
I'm working in 2022 again (new employer), I've resolved the LevelOfDetail issue sending command line input to inactive drawings (fixed in newer versions) by Veto()-ing PREVIEW, etc, but want user to be able to hit enter again, and it go back to PREVIEW.
It's been a few years since I've written code (spending most of my time with wife & toddler), so thanks for the guidance in advance! :beer:
Cheers
public static void onCommandEnded(object sender, CommandEventArgs e)
{
try
{
//if sysvar == 1
if (CoreUtils.WcMatch(e.GlobalCommandName.ToUpper(), "PREVIEW") &&
1 == Convert.ToInt16(acApp.GetSystemVariable(varName)))
{
acDocs.MdiActiveDocument.CommandCancelled -= onCommandEnded;
acDocs.MdiActiveDocument.CommandEnded -= onCommandEnded;
acDocs.MdiActiveDocument.CommandFailed -= onCommandEnded;
acDocs.DocumentLockModeChanged += onDocumentLockModeChanged;
if (!levelOfDetail)
{
//acDocs.MdiActiveDocument.SendStringToExecute("LEVELOFDETAIL" + " ", false, false, false);
acDocs.MdiActiveDocument.SendStringToExecute("LODPREVIEW" + " ", false, false, false);
//levelOfDetail = true;
}
}
}
catch (System.Exception ex)
{
if (acDocs.MdiActiveDocument != null)
acDocs.MdiActiveDocument.Editor.WriteMessage("\n; error: System.Exception: " + ex.Message + "\n");
}
}
public static void onDocumentLockModeChanged(object sender, DocumentLockModeChangedEventArgs e)
{
try
{
if (CoreUtils.WcMatch(e.GlobalCommandName.ToUpper(), "PREVIEW"))
{
if (1 == Convert.ToInt16(acApp.GetSystemVariable(varName))
&& levelOfDetail)
{
acDocs.DocumentLockModeChanged -= onDocumentLockModeChanged;
acDocs.MdiActiveDocument.CommandCancelled += onCommandEnded;
acDocs.MdiActiveDocument.CommandEnded += onCommandEnded;
acDocs.MdiActiveDocument.CommandFailed += onCommandEnded;
e.Veto();
//levelOfDetail = false;
acDocs.MdiActiveDocument.SendStringToExecute("LODPREVIEW" + " ", false, false, false);
//acDocs.MdiActiveDocument.SendStringToExecute("LEVELOFDETAILOFF" + " ", false, false, false);
//acDocs.MdiActiveDocument.SendStringToExecute("PREVIEW" + " ", false, false, false);
}
}
}
catch (System.Exception ex)
{
if (acDocs.MdiActiveDocument != null)
acDocs.MdiActiveDocument.Editor.WriteMessage("\n; error: System.Exception: " + ex.Message + "\n");
}
}
// this isn't working:
[CommandMethod("LODPREVIEW", CommandFlags.NoHistory)]
public void LevelOfDetailPreview()
{
Editor ed = acDocs.MdiActiveDocument.Editor;
try
{
if (levelOfDetail)
{
levelOfDetail = false;
acDocs.MdiActiveDocument.SendStringToExecute("LEVELOFDETAILOFF" + " ", false, false, false);
acDocs.MdiActiveDocument.SendStringToExecute("PREVIEW" + " ", false, false, false);
}
else
{
levelOfDetail = true;
acDocs.MdiActiveDocument.SendStringToExecute("LEVELOFDETAIL" + " ", false, false, false);
}
}
catch (System.Exception ex)
{
if (acDocs.MdiActiveDocument != null)
acDocs.MdiActiveDocument.Editor.WriteMessage("\n; error: System.Exception: " + ex.Message + "\n");
}
}
"How we think determines what we do, and what we do determines what we get."
Solved! Go to Solution.