<?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 Re: Trueview api in Vault Customization Forum</title>
    <link>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8722521#M5222</link>
    <description>&lt;P&gt;Looks like its possible a cool orange do it, just need to figure out how...&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.coolorange.com/wiki/doku.php?id=powerjobs:jobprocessor:file_conversion" target="_blank"&gt;https://www.coolorange.com/wiki/doku.php?id=powerjobs:jobprocessor:file_conversion&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Apr 2019 06:01:16 GMT</pubDate>
    <dc:creator>connor.ferguson</dc:creator>
    <dc:date>2019-04-11T06:01:16Z</dc:date>
    <item>
      <title>Trueview api</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8721395#M5221</link>
      <description>&lt;P&gt;I have a need to convert AutoCAD .dwgs to pdf / dxf. I know you can do this manually through Trueview and the Vault Job Processor uses trueview to create the pdfs on state change. Does Trueview have an api so i can publish them myself? Or can anyone recommend a good 3rd party library? I know the design automation api in forge now has autocad PDF plot but i’d want to avoid uploading to the cloud if possible.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2019 17:46:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8721395#M5221</guid>
      <dc:creator>connor.ferguson</dc:creator>
      <dc:date>2019-04-10T17:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Trueview api</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8722521#M5222</link>
      <description>&lt;P&gt;Looks like its possible a cool orange do it, just need to figure out how...&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.coolorange.com/wiki/doku.php?id=powerjobs:jobprocessor:file_conversion" target="_blank"&gt;https://www.coolorange.com/wiki/doku.php?id=powerjobs:jobprocessor:file_conversion&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 06:01:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8722521#M5222</guid>
      <dc:creator>connor.ferguson</dc:creator>
      <dc:date>2019-04-11T06:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Trueview api</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8790273#M5223</link>
      <description>&lt;P&gt;yes, it is possible, we do this today, though not with TrueView.&amp;nbsp; What we use is the ACCORECONSOLE.exe - which for all intents and purposes is a headless version of AutoCAD that can run AutoCAD plugins.&amp;nbsp; We wrote a plugin many years ago that can go through a drawing and plot the views/layouts in it to PDF/DWF/TIFF/whatever.&amp;nbsp; We just use a script to tell ACCORECONSOLE to load that plugin and generate the views for the drawing.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are lots of examples of this using the .NET API for AutoCAD online, but I could maybe post some sanitized examples here if you would like to see them.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 15:07:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8790273#M5223</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-14T15:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trueview api</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8790449#M5224</link>
      <description>&lt;P&gt;That is very interesting. I'm ok using the AutoCAD .NET API to produce the outputs I want. If you could post the script you use to tell&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #666666; font-family: 'Artifakt',Tahoma,Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;ACCORECONSOLE.exe&lt;/SPAN&gt; that would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 16:19:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8790449#M5224</guid>
      <dc:creator>connor.ferguson</dc:creator>
      <dc:date>2019-05-14T16:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Trueview api</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8793134#M5225</link>
      <description>&lt;P&gt;I can't give you a full on working solution, but I think I can give you enough code and steps to get you moving in a direction.&amp;nbsp; First off, your going to need an AutoCAD plugin that will open a file, find a layout, and print that layout using the plot settings and media settings for that particular layout (or provide settings and media to plot against).&amp;nbsp; There are probably several out there that you can use, we wrote our own because we have our own settings and media.&amp;nbsp; Here is some code to sort of show you a way to do it - its the two methods that do most of the heavy lifting as far as printing.&amp;nbsp; You can use this as a basis to write your own DLL that can be loaded as a plugin:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/// &amp;lt;summary&amp;gt;
/// Generates views from a drawing document.
/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name="tbl"&amp;gt;The Titleblocklayout (our target).&amp;lt;/param&amp;gt;
/// &amp;lt;param name="sizeStandard"&amp;gt;The size standard - ANSI or our custom.&amp;lt;/param&amp;gt;
/// &amp;lt;param name="outputDevice"&amp;gt;The device/driver to plot to&amp;lt;/param&amp;gt;
/// &amp;lt;returns&amp;gt;True is successful, false otherwise.&amp;lt;/returns&amp;gt;
public bool GeneratePlotfilefromDocument(TitleBlockLayout tbl, string sizeStandard, string outputDevice, string layoutName)
{
	string filename = string.Empty;
	string extension = ".cal";
	if (outputDevice.Equals(DWF_DEVICE))
	extension = ".dwf";
	else if (outputDevice.Equals(HPGL_DEVICE))
	extension = ".hpg";

	bool isMultiSheet = false;

	var doc = ThisCommandClass.GetDocumentByName(tbl.DrawingPath);
	if (null == doc) return false;

	if (ACADApp.Application.DocumentManager.MdiActiveDocument != doc)
	ACADApp.Application.DocumentManager.MdiActiveDocument = doc;

	object bgPlot = ACADApp.Application.GetSystemVariable("BackGroundPlot");
	ACADApp.Application.SetSystemVariable("BackGroundPlot", 0);

	object trasparencyPlot = ACADApp.Application.GetSystemVariable("PLOTTRANSPARENCYOVERRIDE");
	ACADApp.Application.SetSystemVariable("PLOTTRANSPARENCYOVERRIDE", 0);

	Layout targetLayout = null;
	using (ACADApp.DocumentLock dl = ACADApp.Application.DocumentManager.MdiActiveDocument.LockDocument())
	{
	using (Transaction tr = ACADApp.Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction())
	{
		var layoutDic = tr.GetObject(ACADApp.Application.DocumentManager.MdiActiveDocument.Database.LayoutDictionaryId, OpenMode.ForRead) as DBDictionary;
		if (layoutDic == null) return false;
		isMultiSheet = (layoutDic.Count &amp;gt;= 2);
		foreach (var layoutRef in layoutDic)
		{
			var layout = layoutRef.Value.GetObject(OpenMode.ForRead) as Layout;
			if (null == layout) continue;
			var btr = layout.BlockTableRecordId.GetObject(OpenMode.ForRead) as BlockTableRecord;
			if (null == btr) continue;

			if (layout.LayoutName.Equals(layoutName))
			{
				targetLayout = layout;
				LayoutManager.Current.CurrentLayout = targetLayout.LayoutName;
				break;
			}
		}

		if (null == targetLayout)
			return false;

		//Create a publish engine and then send the plot through
		PlotEngine pltEng = PlotFactory.CreatePublishEngine();

		try
		{
			LayoutManager layoutMgr = LayoutManager.Current;
			ObjectId layoutId = layoutMgr.GetLayoutId(layoutMgr.CurrentLayout);
			PlotSettings pltSettings = new PlotSettings(targetLayout.ModelType);
			pltSettings.CopyFrom(targetLayout);
			pltSettings.PrintLineweights = true;
			PlotSettingsValidator psv = PlotSettingsValidator.Current;
			string pltdevice = outputDevice; //userConfigSettings.CALPLOTTERCONFIG; 
			string media = customConfigMedia(tbl.Size, pltdevice, sizeStandard);
			if (string.IsNullOrEmpty(media))
			{
				MessageBox.Show("Plot files not found, please contact Tech Support.");
				return false;
			}

			psv.SetPlotType(pltSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
			psv.SetUseStandardScale(pltSettings, true);
			psv.SetStdScaleType(pltSettings, StdScaleType.StdScale1To1);
			psv.SetPlotCentered(pltSettings, true);
			//need the get before the set to avoid error
			psv.GetPlotStyleSheetList();
			if (outputDevice.Equals(CAL_DEVICE))
				psv.SetCurrentStyleSheet(pltSettings, "monochrome.ctb");
			else
				psv.SetCurrentStyleSheet(pltSettings, "acad.ctb");

				psv.SetPlotConfigurationName(pltSettings, pltdevice, media);
			psv.SetPlotRotation(pltSettings, PlotRotation.Degrees000);
			psv.SetPlotPaperUnits(pltSettings, PlotPaperUnit.Inches);
			pltEng.BeginPlot(null, null);
			PlotInfo pltInfo = new PlotInfo();
			pltInfo.Layout = targetLayout.ObjectId;
			pltInfo.OverrideSettings = pltSettings;
			PlotInfoValidator validator = new PlotInfoValidator();
			validator.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
			validator.Validate(pltInfo);
			filename = Path.Combine(Path.GetDirectoryName(tbl.DrawingPath), targetLayout.LayoutName + extension);
			pltEng.BeginDocument(pltInfo, ACADApp.Application.DocumentManager.MdiActiveDocument.Name, null, 1, true, filename);
			PlotPageInfo pageInfo = new PlotPageInfo();
			pltEng.BeginPage(pageInfo, pltInfo, true, null);
			pltEng.BeginGenerateGraphics(null);
			pltEng.EndGenerateGraphics(null);
			pltEng.EndPage(null);
			pltEng.EndDocument(null);
			pltEng.EndPlot(null);
		}
		catch (System.Exception es)
		{
			return false;
		}
		finally
		{
			pltEng.Destroy();
			tr.Commit();
		}
	}

	ACADApp.Application.SetSystemVariable("BackGroundPlot", bgPlot);
	ACADApp.Application.SetSystemVariable("PLOTTRANSPARENCYOVERRIDE", trasparencyPlot);
	return true;
}

/// Retrieves the correct driver from the AutoCAD driver information configuration
/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name="size"&amp;gt;The size of the drawing we are plotting.&amp;lt;/param&amp;gt;
/// &amp;lt;param name="device"&amp;gt;The device/driver name.&amp;lt;/param&amp;gt;
/// &amp;lt;param name="standard"&amp;gt;The size standard - either ANSI or our custom&amp;lt;/param&amp;gt;
/// &amp;lt;returns&amp;gt;The name of the driver media device we are looking for.&amp;lt;/returns&amp;gt;
private string customConfigMedia(string size, string device, string standard)
{
	string mediaSize = string.Empty;
	string target = string.Empty;
	foreach (PlotConfigInfo inf in PlotConfigManager.Devices)
	{
		if (inf.DeviceName.ToUpper().Equals( device.ToUpper() ) )
		{
			PlotConfig pc = PlotConfigManager.SetCurrentConfig(inf.DeviceName);
			//our custom target PC3/PMP files have sizes in them that are named this way
			target = string.Format("TRANSMISSION {0} {1}", standard, size).ToUpper();

			foreach (string media in pc.CanonicalMediaNames)
			{
				if (pc.GetLocalMediaName(media).ToUpper().Equals(target))
				{
					mediaSize = media;
					break;
				}
			}
		}
	}
	return mediaSize;
}&lt;/PRE&gt;
&lt;P&gt;Now, lets assume you have a DLL that is called "MY_PRINTER.dll" and it has a method in there called "PlotLayouts() that gets a layout from the drawing and feeds it into the method above (our drawing layouts are wrapped in an object called TitleBlockLayout but it's essentially an AutoCAD layout object).&amp;nbsp; Your gonna want to basically tell ACCORECONSOLE (which is AutoCAD) to load the drawing and call your method to generate the views.&amp;nbsp; You can do that with an SCR (script) file&amp;nbsp; called "print_my_files.scr" like this:&lt;/P&gt;
&lt;PRE&gt;FILEDIA
0
NETLOAD C:\&amp;lt;whatever the path to your MY_PRINTER.dll library&amp;gt;\MY_PRINTER.dll
PlotLayouts
FILEDIA
1&lt;/PRE&gt;
&lt;P&gt;From there, you can use a command prompt, batch file, whatever to call ACCORECONSOLE and netload that DLL into it&amp;nbsp; with the script and do your work:&lt;/P&gt;
&lt;PRE&gt;C:\Program Files\Autodesk\AutoCAD 2019&amp;gt;accoreconsole.exe /i "C:\blee\blah\drawingtoprint.dwg" /s "C:\blah\blee\print_my_files.scr"&lt;/PRE&gt;
&lt;P&gt;Simple 72 step process &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 16:07:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8793134#M5225</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-15T16:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Trueview api</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8793165#M5226</link>
      <description>&lt;P&gt;That's some good work! Thanks for the info!&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 16:18:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/trueview-api/m-p/8793165#M5226</guid>
      <dc:creator>connor.ferguson</dc:creator>
      <dc:date>2019-05-15T16:18:28Z</dc:date>
    </item>
  </channel>
</rss>

