<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic how to turn on &amp;quot;Plot with plot styles&amp;quot; in the code? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-turn-on-quot-plot-with-plot-styles-quot-in-the-code/m-p/11743352#M10053</link>
    <description>&lt;P&gt;hi, I tried to print in black and white. I found, if "&lt;SPAN&gt;Plot with plot styles" is checked, then it's black and white. but if it's not checked, then the output still colored. how I can make sure&amp;nbsp;"Plot with plot styles" is checked in my code.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;here is my code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;private static bool PublishFile(string outputFilename,
	string mediaName,
	string styleSheetName,
	string plotDeviceName,
	int intStdScaleType)
{
	PlotRotation myPlotRotation = PlotRotation.Degrees000;

	bool ret = false;

	BlockTableRecord btr = Active.Database.CurrentSpaceId.GetObject&amp;lt;BlockTableRecord&amp;gt;();
	Layout lo = btr.LayoutId.GetObject&amp;lt;Layout&amp;gt;();

	// We need a PlotInfo object linked to the layout
	PlotInfo pi = new PlotInfo();
	pi.Layout = btr.LayoutId;

	// We need a PlotSettings object based on the layout settings which we then customize
	PlotSettings ps = new PlotSettings(lo.ModelType);
	ps.CopyFrom(lo);

	// The PlotSettingsValidator helps create a valid PlotSettings object
	PlotSettingsValidator psv = PlotSettingsValidator.Current;

	// We'll plot the extents, centered and scaled to fit
	psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
	//
	psv.SetUseStandardScale(ps, true);
	//psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
	StdScaleType myStdScaleType = StdScaleType.ScaleToFit;
	if (Enum.IsDefined(typeof(StdScaleType), intStdScaleType))
	{
		myStdScaleType = (StdScaleType)intStdScaleType;
	}
	psv.SetStdScaleType(ps, myStdScaleType);
	//
	try
	{
		//psv.SetPlotCentered(ps, true);
		psv.SetPlotCentered(ps, false);
		psv.SetPlotOrigin(ps, new Point2d(0, 0));
		//psv.SetPlotPaperUnits(ps, PlotPaperUnit.Inches);
		//psv.SetPlotPaperUnits(ps, PlotPaperUnit.Millimeters);
		psv.SetPlotRotation(ps, myPlotRotation);
	}
	catch (System.Exception caught)
	{
		throw;
	}

	// print in color or black/white 
	psv.RefreshLists(ps);

	//
	psv.SetCurrentStyleSheet(ps, styleSheetName);

	//
	psv.SetPlotConfigurationName(ps, plotDeviceName, mediaName);

	// We need to link the PlotInfo to the PlotSettings and then validate it
	pi.OverrideSettings = ps;
	PlotInfoValidator piv = new PlotInfoValidator();
	piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
	piv.Validate(pi);

	// A PlotEngine does the actual plotting (can also create one for Preview)
	if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
	{
		PlotEngine pe = PlotFactory.CreatePublishEngine();
		using (pe)
		{
			pe.BeginPlot(null, null);

			// We'll be plotting a single document
			pe.BeginDocument(pi, Active.Document.Name, null, 1, true, outputFilename);

			PlotPageInfo ppi = new PlotPageInfo();
			pe.BeginPage(ppi, pi, true, null);
			pe.BeginGenerateGraphics(null);
			pe.EndGenerateGraphics(null);

			// Finish the sheet
			pe.EndPage(null);
			// Finish the document
			pe.EndDocument(null);
			pe.EndPlot(null);
		}
		ret = true;
	}
	else
	{
		ret = false;
	}

	return ret;
}
&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-02-09 094750.png" style="width: 628px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1174437i1147E88F72023B79/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-02-09 094750.png" alt="Screenshot 2023-02-09 094750.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2023 17:48:30 GMT</pubDate>
    <dc:creator>wesbird</dc:creator>
    <dc:date>2023-02-09T17:48:30Z</dc:date>
    <item>
      <title>how to turn on "Plot with plot styles" in the code?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-turn-on-quot-plot-with-plot-styles-quot-in-the-code/m-p/11743352#M10053</link>
      <description>&lt;P&gt;hi, I tried to print in black and white. I found, if "&lt;SPAN&gt;Plot with plot styles" is checked, then it's black and white. but if it's not checked, then the output still colored. how I can make sure&amp;nbsp;"Plot with plot styles" is checked in my code.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;here is my code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;private static bool PublishFile(string outputFilename,
	string mediaName,
	string styleSheetName,
	string plotDeviceName,
	int intStdScaleType)
{
	PlotRotation myPlotRotation = PlotRotation.Degrees000;

	bool ret = false;

	BlockTableRecord btr = Active.Database.CurrentSpaceId.GetObject&amp;lt;BlockTableRecord&amp;gt;();
	Layout lo = btr.LayoutId.GetObject&amp;lt;Layout&amp;gt;();

	// We need a PlotInfo object linked to the layout
	PlotInfo pi = new PlotInfo();
	pi.Layout = btr.LayoutId;

	// We need a PlotSettings object based on the layout settings which we then customize
	PlotSettings ps = new PlotSettings(lo.ModelType);
	ps.CopyFrom(lo);

	// The PlotSettingsValidator helps create a valid PlotSettings object
	PlotSettingsValidator psv = PlotSettingsValidator.Current;

	// We'll plot the extents, centered and scaled to fit
	psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
	//
	psv.SetUseStandardScale(ps, true);
	//psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
	StdScaleType myStdScaleType = StdScaleType.ScaleToFit;
	if (Enum.IsDefined(typeof(StdScaleType), intStdScaleType))
	{
		myStdScaleType = (StdScaleType)intStdScaleType;
	}
	psv.SetStdScaleType(ps, myStdScaleType);
	//
	try
	{
		//psv.SetPlotCentered(ps, true);
		psv.SetPlotCentered(ps, false);
		psv.SetPlotOrigin(ps, new Point2d(0, 0));
		//psv.SetPlotPaperUnits(ps, PlotPaperUnit.Inches);
		//psv.SetPlotPaperUnits(ps, PlotPaperUnit.Millimeters);
		psv.SetPlotRotation(ps, myPlotRotation);
	}
	catch (System.Exception caught)
	{
		throw;
	}

	// print in color or black/white 
	psv.RefreshLists(ps);

	//
	psv.SetCurrentStyleSheet(ps, styleSheetName);

	//
	psv.SetPlotConfigurationName(ps, plotDeviceName, mediaName);

	// We need to link the PlotInfo to the PlotSettings and then validate it
	pi.OverrideSettings = ps;
	PlotInfoValidator piv = new PlotInfoValidator();
	piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
	piv.Validate(pi);

	// A PlotEngine does the actual plotting (can also create one for Preview)
	if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
	{
		PlotEngine pe = PlotFactory.CreatePublishEngine();
		using (pe)
		{
			pe.BeginPlot(null, null);

			// We'll be plotting a single document
			pe.BeginDocument(pi, Active.Document.Name, null, 1, true, outputFilename);

			PlotPageInfo ppi = new PlotPageInfo();
			pe.BeginPage(ppi, pi, true, null);
			pe.BeginGenerateGraphics(null);
			pe.EndGenerateGraphics(null);

			// Finish the sheet
			pe.EndPage(null);
			// Finish the document
			pe.EndDocument(null);
			pe.EndPlot(null);
		}
		ret = true;
	}
	else
	{
		ret = false;
	}

	return ret;
}
&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-02-09 094750.png" style="width: 628px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1174437i1147E88F72023B79/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-02-09 094750.png" alt="Screenshot 2023-02-09 094750.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 17:48:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-turn-on-quot-plot-with-plot-styles-quot-in-the-code/m-p/11743352#M10053</guid>
      <dc:creator>wesbird</dc:creator>
      <dc:date>2023-02-09T17:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to turn on "Plot with plot styles" in the code?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-turn-on-quot-plot-with-plot-styles-quot-in-the-code/m-p/11743564#M10054</link>
      <description>&lt;P&gt;psv.SetCurrentStyleSheet(xxxx, "[A Mono PlotStyle Sheet].ctb");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to first call PlotSettingValidator.GetPlotStyleSheetList() to see if the desired "mono-color" style sheet is available or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 19:23:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-turn-on-quot-plot-with-plot-styles-quot-in-the-code/m-p/11743564#M10054</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-02-09T19:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to turn on "Plot with plot styles" in the code?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-turn-on-quot-plot-with-plot-styles-quot-in-the-code/m-p/11746400#M10055</link>
      <description>&lt;P&gt;Ensure that your layout (lo) is opened for write.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;lo.PlotPlotStyles = True;&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 10 Feb 2023 19:59:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-turn-on-quot-plot-with-plot-styles-quot-in-the-code/m-p/11746400#M10055</guid>
      <dc:creator>hippe013</dc:creator>
      <dc:date>2023-02-10T19:59:52Z</dc:date>
    </item>
  </channel>
</rss>

