Engine中调用StackProfile_3d工具,想要生成.grf文件,最后一个可选参数如何写?

Engine中调用StackProfile_3d工具,最后一个可选参数out_graph如何写?ArcMap直接给个string类型名称就可以成功,Engine中无论使用绝对路径还是名称都报错
已邀请:

朱新颖

赞同来自:

【解决办法】:
由于Engine中没有提供创建Graph的接口,所以使用Engine许可调用StackProfile_3d工具,无法直接生成图表,即out_graph参数怎么设置都会报错;
但是使用Desktop许可(即Basic,Standard,Advanced中的一个),可以设置out_graph参数,即图表的名称,生成一个在内存中的图表,可以接着调用SaveGraph工具生成.grf文件

参考代码如下:
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop); //这里绑定EngineOrDesktop会报错
AoInitialize aoi = new AoInitializeClass();
aoi.Initialize(esriLicenseProductCode.esriLicenseProductCodeBasic);
aoi.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst);
ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
gp.OverwriteOutput = true;

StackProfile stackProfile = new ESRI.ArcGIS.Analyst3DTools.StackProfile();
stackProfile.in_line_features = @D:\ZhuXinying\testData\测试数据\polylineCut.shp;
stackProfile.profile_targets = @ D:\ZhuXinying\testData\测试数据\dtm_tincopy3;
stackProfile.out_table = @D:\ZhuXinying\testData\测试数据\table3;
stackProfile.out_graph = zxyfile;
GeoProcessorResult gpResult = new GeoProcessorResult();
try
{
gp.Execute(stackProfile, null); }

catch (Exception ex)
{
// Print geoprocessing execution error messages.
for (int i = 0; i < gp.MessageCount; i++)
Console.WriteLine(gp.GetMessage(i));
}
SaveGraph saveG = new SaveGraph();
saveG.in_graph = zxyfile;
saveG.out_graph_file = @D:\ZhuXinying\temp\zxy.grf;
try
{
gp.Execute(saveG, null);
}
catch (Exception ex)
{
// Print geoprocessing execution error messages.
for (int i = 0; i < gp.MessageCount; i++)
Console.WriteLine(gp.GetMessage(i));
}

要回复问题请先登录注册