如何在海洋中添加Petrel中的自定义单位?
问题描述:
我想通过海洋在Petrel的自定义单元系统中添加自定义单元。
正如开发者指南的建议,我用下面的代码:如何在海洋中添加Petrel中的自定义单位?
IUnitService unitService = Slb.Ocean.Core.CoreSystem.GetService();
IUnitCatalog catalog = unitService.GetCatalog(null);
System.Collections.Generic.IDictionary map =
new System.Collections.Generic.Dictionary();
map["Pressure"] = "MyUnit";
catalog.CreateCustomUnitSystem("My UnitSystem",
"UnitSystem for my additional units.",
map,
"MyUnitSystem");
我把这些代码在初始化和集成方法。 在这两种情况下,Ocean都会抛出一个SEHException。
任何想法出了什么问题?
答
您创建的自定义单位系统必须基于现有单位制。
现有单位系统名称用作方法CreateCustomUnitSystem中的参考系统。
现有单元系统包括可从IUnitServiceSettings获得的Canonical和Display单元系统。
下面是创建一个定制单元系统中的示例代码:
IUnitService unitService = CoreSystem.GetService();
IUnitCatalog catalog = unitService.GetCatalog(null);
IUnitServiceSettings uss = CoreSystem.GetService();
IUnitSystem refSystem = uss.InvariantSystem;
IDictionary map = new Dictionary();
map["Pressure"] = "MyUnit";
ICustomUnitSystem myUnitSystem = catalog.CreateCustomUnitSystem("My UnitSystem", "Unit System for my additional units.", map, refSystem.Name);
定制单元系统不会改变任何的Petrel模板,也不会被添加到模板选项卡中的Petrel Explorer窗口