在 Forge Design Automation 中更改打印机支持文件路径 API
Changing Printer Support File Path in Forge Design Automation API
在 AutoCAD 设计自动化中 API - 如何更改选项 --> 文件(选项卡)--> 打印机支持文件路径 --> 打印样式 Table 搜索路径到在工作项执行期间指向另一个位置?我尝试调整包内容 xml 文件中的 RuntimeRequirements 以指向我的包内容,但这没有用。
<Components>
<RuntimeRequirements
OS="Win64"
Platform="AutoCAD"
SupportPath="./Contents/"/>
.......
有什么建议吗?最终我试图上传一个特定的自定义 ctb 文件并用它绘制
谢谢,
约翰
您需要编程将相关文件从包复制到自定义插件 dll 中的 Plotter 文件夹。
假设您将.pmp、.pc3、.ctb等所有相关文件都放在了Contents文件夹中,如图
示例:
然后您需要 运行 命令,然后再 运行 执行任何 PLOT 命令。这将在您对已上传到 DA 服务的捆绑包执行 workItem 时将文件复制到相关文件夹。
[CommandMethod("PlotLayoutCommands", "COPYPLOTTERFILES", CommandFlags.Modal)]
public static void CopyPlotterFiles()
{
// Get the current document and database, and start a transaction
Document acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
//A way to copy files from bundle package to respective Printer Support Path
object roamablePath = Autodesk.AutoCAD.ApplicationServices.Core.Application.GetSystemVariable("ROAMABLEROOTPREFIX");
acDoc.Editor.WriteMessage("\nRoamable-Path\t:{0}\n", roamablePath.ToString());
string pc3FileFound = HostApplicationServices.Current.FindFile("DAS-PDF.pc3", acCurDb, FindFileHint.Default);
string pmpFileFound = HostApplicationServices.Current.FindFile("DAS-PDF.pmp", acCurDb, FindFileHint.Default);
string plotStyleFileFound = HostApplicationServices.Current.FindFile("DAS-PDF.ctb", acCurDb, FindFileHint.Default);
string scriptFileFound = HostApplicationServices.Current.FindFile("RunPlot.scr", acCurDb, FindFileHint.Default);
acDoc.Editor.WriteMessage("\nPC3 Config\t:{0}\n", pc3FileFound);
acDoc.Editor.WriteMessage("\nPMP File\t:{0}\n", pmpFileFound);
acDoc.Editor.WriteMessage("\nCTB File\t:{0}\n", plotStyleFileFound);
acDoc.Editor.WriteMessage("\nScript File\t:{0}\n", scriptFileFound);
//Start Copying:
string pmpFolder = "PMP Files";
string pc3Folder = "Plotters";
string plotStylesFolder = "Plot Styles";
try
{
File.Copy(pc3FileFound,
Path.Combine(roamablePath.ToString(),
pc3Folder, Path.GetFileName(pc3FileFound)));
File.Copy(pmpFileFound,
Path.Combine(roamablePath.ToString(),
pc3Folder, pmpFolder, Path.GetFileName(pmpFileFound)));
File.Copy(plotStyleFileFound, Path.Combine(roamablePath.ToString(),
pc3Folder, plotStylesFolder, Path.GetFileName(plotStyleFileFound)));
File.Copy(scriptFileFound, Path.Combine(Directory.GetCurrentDirectory(), Path.GetFileName(plotStyleFileFound)));
}
catch (System.Exception ex)
{
acDoc.Editor.WriteMessage("\n" + ex.Message);
}
}
或
您可以像这样创建 CustomPlot 命令,这将在布局上设置 PC3 和 CTB。
public static void PlotLayout()
{
// Get the current document and database, and start a transaction
Document acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
//A way to copy files from bundle package to respective Printer Support Path
object roamablePath = Autodesk.AutoCAD.ApplicationServices.Core.Application.GetSystemVariable("ROAMABLEROOTPREFIX");
acDoc.Editor.WriteMessage("\nRoamable-Path\t:{0}\n", roamablePath.ToString());
string pc3FileFound = HostApplicationServices.Current.FindFile("DAS-PDF.pc3", acCurDb, FindFileHint.Default);
string pmpFileFound = HostApplicationServices.Current.FindFile("DAS-PDF.pmp", acCurDb, FindFileHint.Default);
string plotStyleFileFound = HostApplicationServices.Current.FindFile("DAS-PDF.ctb", acCurDb, FindFileHint.Default);
acDoc.Editor.WriteMessage("\nPC3 Config\t:{0}\n", pc3FileFound);
acDoc.Editor.WriteMessage("\nPMP File\t:{0}\n", pmpFileFound);
acDoc.Editor.WriteMessage("\nCTB File\t:{0}\n", plotStyleFileFound);
//Start Copying:
string pmpFolder = "PMP Files";
string pc3Folder = "Plotters";
string plotStylesFolder = "Plot Styles";
try
{
File.Copy(pc3FileFound,
Path.Combine(roamablePath.ToString(),
pc3Folder, Path.GetFileName(pc3FileFound)),true);
File.Copy(pmpFileFound,
Path.Combine(roamablePath.ToString(),
pc3Folder, pmpFolder, Path.GetFileName(pmpFileFound)), true);
File.Copy(plotStyleFileFound, Path.Combine(roamablePath.ToString(),
pc3Folder, plotStylesFolder, Path.GetFileName(plotStyleFileFound)), true);
}
catch (System.Exception ex)
{
acDoc.Editor.WriteMessage("\n" + ex.Message);
}
// these prompts are only seen when running in interactive mode in autocad
// when they are run from the activity, they are passed in as part of the script (like parameters)
PromptResult result = acDoc.Editor.GetString("Enter PC3 File:");
if (result.Status != PromptStatus.OK) return;
string pc3FileName = result.StringResult;
result = acDoc.Editor.GetString("Enter CTB File:");
if (result.Status != PromptStatus.OK) return;
string ctbFileName = result.StringResult;
result = acDoc.Editor.GetString("Enter PDF Name :");
if (result.Status != PromptStatus.OK) return;
string pdfFileName = result.StringResult;
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Reference the Layout Manager
LayoutManager acLayoutMgr = LayoutManager.Current;
// Get the current layout and output its name in the Command Line window
Layout acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout),
OpenMode.ForRead) as Layout;
using (OpenCloseTransaction oct = new OpenCloseTransaction())
{
using (PlotSettingsValidator plotSetVal = PlotSettingsValidator.Current)
{
acDoc.Editor.WriteMessage($"\nStyle sheet of current layout:{acLayout.CurrentStyleSheet}");
if (!acLayout.IsWriteEnabled)
{
acLayout.UpgradeOpen();
}
plotSetVal.RefreshLists(acLayout);
if (plotSetVal.GetPlotStyleSheetList().Contains(ctbFileName))
{
if (acCurDb.PlotStyleMode)
{
acDoc.Editor.WriteMessage($"\nThe plot style sheet is being set to {ctbFileName}");
plotSetVal.SetCurrentStyleSheet(acLayout, ctbFileName);
}
else
{
acDoc.Editor.WriteMessage("\nUnable to set plot style in drawing using stb\n\n");
}
}
}
oct.Commit();
}
PlotConfig acPlCfg = PlotConfigManager.SetCurrentConfig(pc3FileName);
string mediaName = acPlCfg.Comment;
// Get the PlotInfo from the layout
using (PlotInfo acPlInfo = new PlotInfo())
{
acPlInfo.Layout = acLayout.ObjectId;
// Get a copy of the PlotSettings from the layout
using (PlotSettings acPlSet = new PlotSettings(acLayout.ModelType))
{
acPlSet.CopyFrom(acLayout);
// Update the PlotSettings object
PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
// Set the plot type
acPlSetVdr.SetPlotType(acPlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
// Set the plot scale
acPlSetVdr.SetUseStandardScale(acPlSet, true);
acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit);
// Center the plot
acPlSetVdr.SetPlotCentered(acPlSet, true);
// Set the plot device to use
acPlSetVdr.SetPlotConfigurationName(acPlSet, Path.GetFileName(pc3FileName), acPlSet.CanonicalMediaName);
// Set the plot info as an override since it will
// not be saved back to the layout
acPlInfo.OverrideSettings = acPlSet;
// Validate the plot info
using (PlotInfoValidator acPlInfoVdr = new PlotInfoValidator())
{
acPlInfoVdr.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
acPlInfoVdr.Validate(acPlInfo);
// Check to see if a plot is already in progress
if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
{
using (PlotEngine acPlEng = PlotFactory.CreatePublishEngine())
{
// Track the plot progress with a Progress dialog
using (PlotProgressDialog acPlProgDlg = new PlotProgressDialog(false, 1, true))
{
using ((acPlProgDlg))
{
// Define the status messages to display
// when plotting starts
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Plot Progress");
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Cancel Job");
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Cancel Sheet");
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Sheet Set Progress");
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Sheet Progress");
// Set the plot progress range
acPlProgDlg.LowerPlotProgressRange = 0;
acPlProgDlg.UpperPlotProgressRange = 100;
acPlProgDlg.PlotProgressPos = 0;
// Display the Progress dialog
acPlProgDlg.OnBeginPlot();
acPlProgDlg.IsVisible = true;
// Start to plot the layout
acPlEng.BeginPlot(acPlProgDlg, null);
// Define the plot output
acPlEng.BeginDocument(acPlInfo, acDoc.Name, null, 1, true, pdfFileName);
// Display information about the current plot
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.Status, "Plotting: " + acDoc.Name + " - " + acLayout.LayoutName);
// Set the sheet progress range
acPlProgDlg.OnBeginSheet();
acPlProgDlg.LowerSheetProgressRange = 0;
acPlProgDlg.UpperSheetProgressRange = 100;
acPlProgDlg.SheetProgressPos = 0;
// Plot the first sheet/layout
using (PlotPageInfo acPlPageInfo = new PlotPageInfo())
{
acPlEng.BeginPage(acPlPageInfo, acPlInfo, true, null);
}
acPlEng.BeginGenerateGraphics(null);
acPlEng.EndGenerateGraphics(null);
// Finish plotting the sheet/layout
acPlEng.EndPage(null);
acPlProgDlg.SheetProgressPos = 100;
acPlProgDlg.OnEndSheet();
// Finish plotting the document
acPlEng.EndDocument(null);
// Finish the plot
acPlProgDlg.PlotProgressPos = 100;
acPlProgDlg.OnEndPlot();
acPlEng.EndPlot(null);
}
}
}
}
}
}
}
}
}
您的 Activity 使用 C# .NET 核心。
private async Task<string> SetupActivityAsync(string myApp)
{
Console.WriteLine("Setting up activity...");
var myActivity = $"{Owner}.{ActivityName}+{Label}";
var actResponse = await this.api.ActivitiesApi.GetActivityAsync(myActivity, throwOnError: false);
var activity = new Activity()
{
Appbundles = new List<string>()
{
myApp
},
CommandLine = new List<string>()
{
$"$(engine.path)\accoreconsole.exe /i $(args[inputFile].path) /al $(appbundles[{PackageName}].path) /s $(settings[script].path)"
},
Engine = TargetEngine,
Settings = new Dictionary<string, ISetting>()
{
{ "script", new StringSetting() { Value = "CustomPlot\nDAS-PDF.pc3\nDAS-PDF.ctb\nresult.pdf\n" } }
},
Parameters = new Dictionary<string, Parameter>()
{
{ "inputFile", new Parameter() { Verb= Verb.Get, LocalName = "$(HostDwg)", Required = true } },
{ "outputFile", new Parameter() { Verb= Verb.Put, LocalName = "result.pdf", Required= true} }
},
Id = ActivityName
};
if (actResponse.HttpResponse.StatusCode == HttpStatusCode.NotFound)
{
Console.WriteLine($"Creating activity {myActivity}...");
await api.CreateActivityAsync(activity, Label);
return myActivity;
}
await actResponse.HttpResponse.EnsureSuccessStatusCodeAsync();
Console.WriteLine("\tFound existing activity...");
if (!Equals(activity, actResponse.Content))
{
Console.WriteLine($"\tUpdating activity {myActivity}...");
await api.UpdateActivityAsync(activity, Label);
}
return myActivity;
}
并且,工作项目:
var workItemStatus = await api.CreateWorkItemAsync(new Autodesk.Forge.DesignAutomation.Model.WorkItem()
{
ActivityId = myActivity,
Arguments = new Dictionary<string, IArgument>() {
{
"inputFile",
new XrefTreeArgument() {
Url = DownloadUrl,
Verb = Verb.Get
}
}, {
"outputFile",
new XrefTreeArgument() {
Verb = Verb.Put, Url = UploadUrl
}
}
}
});
在 AutoCAD 设计自动化中 API - 如何更改选项 --> 文件(选项卡)--> 打印机支持文件路径 --> 打印样式 Table 搜索路径到在工作项执行期间指向另一个位置?我尝试调整包内容 xml 文件中的 RuntimeRequirements 以指向我的包内容,但这没有用。
<Components>
<RuntimeRequirements
OS="Win64"
Platform="AutoCAD"
SupportPath="./Contents/"/>
.......
有什么建议吗?最终我试图上传一个特定的自定义 ctb 文件并用它绘制 谢谢, 约翰
您需要编程将相关文件从包复制到自定义插件 dll 中的 Plotter 文件夹。
假设您将.pmp、.pc3、.ctb等所有相关文件都放在了Contents文件夹中,如图
示例:
然后您需要 运行 命令,然后再 运行 执行任何 PLOT 命令。这将在您对已上传到 DA 服务的捆绑包执行 workItem 时将文件复制到相关文件夹。
[CommandMethod("PlotLayoutCommands", "COPYPLOTTERFILES", CommandFlags.Modal)]
public static void CopyPlotterFiles()
{
// Get the current document and database, and start a transaction
Document acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
//A way to copy files from bundle package to respective Printer Support Path
object roamablePath = Autodesk.AutoCAD.ApplicationServices.Core.Application.GetSystemVariable("ROAMABLEROOTPREFIX");
acDoc.Editor.WriteMessage("\nRoamable-Path\t:{0}\n", roamablePath.ToString());
string pc3FileFound = HostApplicationServices.Current.FindFile("DAS-PDF.pc3", acCurDb, FindFileHint.Default);
string pmpFileFound = HostApplicationServices.Current.FindFile("DAS-PDF.pmp", acCurDb, FindFileHint.Default);
string plotStyleFileFound = HostApplicationServices.Current.FindFile("DAS-PDF.ctb", acCurDb, FindFileHint.Default);
string scriptFileFound = HostApplicationServices.Current.FindFile("RunPlot.scr", acCurDb, FindFileHint.Default);
acDoc.Editor.WriteMessage("\nPC3 Config\t:{0}\n", pc3FileFound);
acDoc.Editor.WriteMessage("\nPMP File\t:{0}\n", pmpFileFound);
acDoc.Editor.WriteMessage("\nCTB File\t:{0}\n", plotStyleFileFound);
acDoc.Editor.WriteMessage("\nScript File\t:{0}\n", scriptFileFound);
//Start Copying:
string pmpFolder = "PMP Files";
string pc3Folder = "Plotters";
string plotStylesFolder = "Plot Styles";
try
{
File.Copy(pc3FileFound,
Path.Combine(roamablePath.ToString(),
pc3Folder, Path.GetFileName(pc3FileFound)));
File.Copy(pmpFileFound,
Path.Combine(roamablePath.ToString(),
pc3Folder, pmpFolder, Path.GetFileName(pmpFileFound)));
File.Copy(plotStyleFileFound, Path.Combine(roamablePath.ToString(),
pc3Folder, plotStylesFolder, Path.GetFileName(plotStyleFileFound)));
File.Copy(scriptFileFound, Path.Combine(Directory.GetCurrentDirectory(), Path.GetFileName(plotStyleFileFound)));
}
catch (System.Exception ex)
{
acDoc.Editor.WriteMessage("\n" + ex.Message);
}
}
或
您可以像这样创建 CustomPlot 命令,这将在布局上设置 PC3 和 CTB。
public static void PlotLayout()
{
// Get the current document and database, and start a transaction
Document acDoc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
//A way to copy files from bundle package to respective Printer Support Path
object roamablePath = Autodesk.AutoCAD.ApplicationServices.Core.Application.GetSystemVariable("ROAMABLEROOTPREFIX");
acDoc.Editor.WriteMessage("\nRoamable-Path\t:{0}\n", roamablePath.ToString());
string pc3FileFound = HostApplicationServices.Current.FindFile("DAS-PDF.pc3", acCurDb, FindFileHint.Default);
string pmpFileFound = HostApplicationServices.Current.FindFile("DAS-PDF.pmp", acCurDb, FindFileHint.Default);
string plotStyleFileFound = HostApplicationServices.Current.FindFile("DAS-PDF.ctb", acCurDb, FindFileHint.Default);
acDoc.Editor.WriteMessage("\nPC3 Config\t:{0}\n", pc3FileFound);
acDoc.Editor.WriteMessage("\nPMP File\t:{0}\n", pmpFileFound);
acDoc.Editor.WriteMessage("\nCTB File\t:{0}\n", plotStyleFileFound);
//Start Copying:
string pmpFolder = "PMP Files";
string pc3Folder = "Plotters";
string plotStylesFolder = "Plot Styles";
try
{
File.Copy(pc3FileFound,
Path.Combine(roamablePath.ToString(),
pc3Folder, Path.GetFileName(pc3FileFound)),true);
File.Copy(pmpFileFound,
Path.Combine(roamablePath.ToString(),
pc3Folder, pmpFolder, Path.GetFileName(pmpFileFound)), true);
File.Copy(plotStyleFileFound, Path.Combine(roamablePath.ToString(),
pc3Folder, plotStylesFolder, Path.GetFileName(plotStyleFileFound)), true);
}
catch (System.Exception ex)
{
acDoc.Editor.WriteMessage("\n" + ex.Message);
}
// these prompts are only seen when running in interactive mode in autocad
// when they are run from the activity, they are passed in as part of the script (like parameters)
PromptResult result = acDoc.Editor.GetString("Enter PC3 File:");
if (result.Status != PromptStatus.OK) return;
string pc3FileName = result.StringResult;
result = acDoc.Editor.GetString("Enter CTB File:");
if (result.Status != PromptStatus.OK) return;
string ctbFileName = result.StringResult;
result = acDoc.Editor.GetString("Enter PDF Name :");
if (result.Status != PromptStatus.OK) return;
string pdfFileName = result.StringResult;
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// Reference the Layout Manager
LayoutManager acLayoutMgr = LayoutManager.Current;
// Get the current layout and output its name in the Command Line window
Layout acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout),
OpenMode.ForRead) as Layout;
using (OpenCloseTransaction oct = new OpenCloseTransaction())
{
using (PlotSettingsValidator plotSetVal = PlotSettingsValidator.Current)
{
acDoc.Editor.WriteMessage($"\nStyle sheet of current layout:{acLayout.CurrentStyleSheet}");
if (!acLayout.IsWriteEnabled)
{
acLayout.UpgradeOpen();
}
plotSetVal.RefreshLists(acLayout);
if (plotSetVal.GetPlotStyleSheetList().Contains(ctbFileName))
{
if (acCurDb.PlotStyleMode)
{
acDoc.Editor.WriteMessage($"\nThe plot style sheet is being set to {ctbFileName}");
plotSetVal.SetCurrentStyleSheet(acLayout, ctbFileName);
}
else
{
acDoc.Editor.WriteMessage("\nUnable to set plot style in drawing using stb\n\n");
}
}
}
oct.Commit();
}
PlotConfig acPlCfg = PlotConfigManager.SetCurrentConfig(pc3FileName);
string mediaName = acPlCfg.Comment;
// Get the PlotInfo from the layout
using (PlotInfo acPlInfo = new PlotInfo())
{
acPlInfo.Layout = acLayout.ObjectId;
// Get a copy of the PlotSettings from the layout
using (PlotSettings acPlSet = new PlotSettings(acLayout.ModelType))
{
acPlSet.CopyFrom(acLayout);
// Update the PlotSettings object
PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
// Set the plot type
acPlSetVdr.SetPlotType(acPlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
// Set the plot scale
acPlSetVdr.SetUseStandardScale(acPlSet, true);
acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit);
// Center the plot
acPlSetVdr.SetPlotCentered(acPlSet, true);
// Set the plot device to use
acPlSetVdr.SetPlotConfigurationName(acPlSet, Path.GetFileName(pc3FileName), acPlSet.CanonicalMediaName);
// Set the plot info as an override since it will
// not be saved back to the layout
acPlInfo.OverrideSettings = acPlSet;
// Validate the plot info
using (PlotInfoValidator acPlInfoVdr = new PlotInfoValidator())
{
acPlInfoVdr.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
acPlInfoVdr.Validate(acPlInfo);
// Check to see if a plot is already in progress
if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
{
using (PlotEngine acPlEng = PlotFactory.CreatePublishEngine())
{
// Track the plot progress with a Progress dialog
using (PlotProgressDialog acPlProgDlg = new PlotProgressDialog(false, 1, true))
{
using ((acPlProgDlg))
{
// Define the status messages to display
// when plotting starts
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Plot Progress");
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Cancel Job");
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Cancel Sheet");
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Sheet Set Progress");
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Sheet Progress");
// Set the plot progress range
acPlProgDlg.LowerPlotProgressRange = 0;
acPlProgDlg.UpperPlotProgressRange = 100;
acPlProgDlg.PlotProgressPos = 0;
// Display the Progress dialog
acPlProgDlg.OnBeginPlot();
acPlProgDlg.IsVisible = true;
// Start to plot the layout
acPlEng.BeginPlot(acPlProgDlg, null);
// Define the plot output
acPlEng.BeginDocument(acPlInfo, acDoc.Name, null, 1, true, pdfFileName);
// Display information about the current plot
acPlProgDlg.set_PlotMsgString(PlotMessageIndex.Status, "Plotting: " + acDoc.Name + " - " + acLayout.LayoutName);
// Set the sheet progress range
acPlProgDlg.OnBeginSheet();
acPlProgDlg.LowerSheetProgressRange = 0;
acPlProgDlg.UpperSheetProgressRange = 100;
acPlProgDlg.SheetProgressPos = 0;
// Plot the first sheet/layout
using (PlotPageInfo acPlPageInfo = new PlotPageInfo())
{
acPlEng.BeginPage(acPlPageInfo, acPlInfo, true, null);
}
acPlEng.BeginGenerateGraphics(null);
acPlEng.EndGenerateGraphics(null);
// Finish plotting the sheet/layout
acPlEng.EndPage(null);
acPlProgDlg.SheetProgressPos = 100;
acPlProgDlg.OnEndSheet();
// Finish plotting the document
acPlEng.EndDocument(null);
// Finish the plot
acPlProgDlg.PlotProgressPos = 100;
acPlProgDlg.OnEndPlot();
acPlEng.EndPlot(null);
}
}
}
}
}
}
}
}
}
您的 Activity 使用 C# .NET 核心。
private async Task<string> SetupActivityAsync(string myApp)
{
Console.WriteLine("Setting up activity...");
var myActivity = $"{Owner}.{ActivityName}+{Label}";
var actResponse = await this.api.ActivitiesApi.GetActivityAsync(myActivity, throwOnError: false);
var activity = new Activity()
{
Appbundles = new List<string>()
{
myApp
},
CommandLine = new List<string>()
{
$"$(engine.path)\accoreconsole.exe /i $(args[inputFile].path) /al $(appbundles[{PackageName}].path) /s $(settings[script].path)"
},
Engine = TargetEngine,
Settings = new Dictionary<string, ISetting>()
{
{ "script", new StringSetting() { Value = "CustomPlot\nDAS-PDF.pc3\nDAS-PDF.ctb\nresult.pdf\n" } }
},
Parameters = new Dictionary<string, Parameter>()
{
{ "inputFile", new Parameter() { Verb= Verb.Get, LocalName = "$(HostDwg)", Required = true } },
{ "outputFile", new Parameter() { Verb= Verb.Put, LocalName = "result.pdf", Required= true} }
},
Id = ActivityName
};
if (actResponse.HttpResponse.StatusCode == HttpStatusCode.NotFound)
{
Console.WriteLine($"Creating activity {myActivity}...");
await api.CreateActivityAsync(activity, Label);
return myActivity;
}
await actResponse.HttpResponse.EnsureSuccessStatusCodeAsync();
Console.WriteLine("\tFound existing activity...");
if (!Equals(activity, actResponse.Content))
{
Console.WriteLine($"\tUpdating activity {myActivity}...");
await api.UpdateActivityAsync(activity, Label);
}
return myActivity;
}
并且,工作项目:
var workItemStatus = await api.CreateWorkItemAsync(new Autodesk.Forge.DesignAutomation.Model.WorkItem()
{
ActivityId = myActivity,
Arguments = new Dictionary<string, IArgument>() {
{
"inputFile",
new XrefTreeArgument() {
Url = DownloadUrl,
Verb = Verb.Get
}
}, {
"outputFile",
new XrefTreeArgument() {
Verb = Verb.Put, Url = UploadUrl
}
}
}
});