This example adds a command named "SetPlotSheet". When this command is run all of the available plot sheets are listed on the command line. Also if the drawing is using .ctb files the stylesheet for the layout is set to "acad.ctb" if it is one of the available style sheets.
[CommandMethod("SetPlotSheet")]
public void SetPlotSheet()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
LayoutManager layManager = LayoutManager.Current;
ObjectId layoutId =
layManager.GetLayoutId(layManager.CurrentLayout);
Layout layoutObj =
(Layout)tr.GetObject(layoutId, OpenMode.ForWrite);
ed.WriteMessage("Style sheet of current layout: "
+ layoutObj.CurrentStyleSheet + "\n");
PlotSettingsValidator plotSetVal =
PlotSettingsValidator.Current;
plotSetVal.RefreshLists(layoutObj);
System.Collections.Specialized.StringCollection sheetList
= plotSetVal.GetPlotStyleSheetList();
ed.WriteMessage("The list of available plot style sheets\n");
foreach (String str in sheetList)
{
ed.WriteMessage(str + "\n");
if (str.ToLower().Equals("acad.ctb"))
{
//find out if drawing is using ctb
System.Object test =
Application.GetSystemVariable("PSTYLEMODE");
if (test.ToString().Equals("1"))
{
// drawing is using ctb so go ahead and
//assign acad.ctb to the layout
ed.WriteMessage("\nThe plot style sheet is" +
" being set to acad.ctb\n\n");
plotSetVal.SetCurrentStyleSheet(layoutObj, str);
}
else
{
ed.WriteMessage("\nUnable to set plot style in" +
" this example, drawing using stb\n\n");
}
}
}
tr.Commit();
}
}