列举几个在pdms中利用pmlnet进行编程 的例子
时间: 2024-03-26 10:35:02 浏览: 148
PMLNet是PDMS中的.NET接口,可以使用C#或VB.NET等.NET语言进行编程。以下是几个在PDMS中利用PMLNet进行编程的例子:
1. 创建新模型:
```
using Aveva.Pdms.Geometry;
using Aveva.PDMS.PMLNet;
[Schema("MyModel")]
public class MyModel : PMLNetObject
{
public MyModel() : base(new DBElement(DbElementTypeInstance.MDL))
{
Element.Create();
Element.Update();
}
}
```
2. 创建新对象:
```
using Aveva.Pdms.Geometry;
using Aveva.PDMS.PMLNet;
public static class MyObject
{
public static void Create(string name, PDMSPoint pos)
{
DBElement elem = new DBElement(DbElementTypeInstance.PLINE);
elem.SetAttribute(DbAttributeInstance.NAME, name);
elem.SetAttribute(DbAttributeInstance.POSIT, pos.ToArray());
elem.Create();
elem.Update();
}
}
```
3. 获取对象属性:
```
using Aveva.Pdms.Geometry;
using Aveva.PDMS.PMLNet;
public static class MyObject
{
public static string GetName(DBElement elem)
{
return elem.GetAsString(DbAttributeInstance.NAME);
}
public static PDMSPoint GetPosition(DBElement elem)
{
double[] pos = elem.GetAsArray(DbAttributeInstance.POSIT);
return new PDMSPoint(pos[0], pos[1], pos[2]);
}
}
```
4. 选择对象:
```
using Aveva.Pdms.Geometry;
using Aveva.PDMS.PMLNet;
public static class MySelection
{
public static DBElement[] GetSelectedObjects()
{
PDMSBoundingBox bbox = PDMSBoundingBox.GetSelection();
return bbox.GetElements();
}
}
```
以上仅是几个简单的例子,PMLNet还可以进行更复杂的编程,例如创建自定义对话框、操作PDMS数据库等。
阅读全文