利用選擇功能
public ModelObjectEnumerator getAllWeldsFromModel()
{
ModelObjectEnumerator.AutoFetch = true;
ObjectFilterExpressions.Type objectType = new ObjectFilterExpressions.Type();
NumericConstantFilterExpression Weld = new NumericConstantFilterExpression(TeklaStructuresDatabaseTypeEnum.WELDING);
var expression1 = new BinaryFilterExpression(objectType, NumericOperatorType.IS_EQUAL, Weld);
BinaryFilterExpressionCollection filterCollection = new BinaryFilterExpressionCollection
{
new BinaryFilterExpressionItem(expression1,BinaryFilterOperatorType.BOOLEAN_AND),,
};
ModelObjectEnumerator moe = model.GetModelObjectSelector()
.GetObjectsByFilter(filterCollection);
moe.SelectInstances = false;
return moe;
}
下面提到我使用的方法,但我的方法返回焊縫計數和手動選擇的焊縫計數有所不同。
public ModelObjectEnumerator getAllWeldsFromModel()
{
ModelObjectEnumerator.AutoFetch = true;
Type[] welds = new Type[] { typeof(BaseWeld) };
ModelObjectEnumerator moe = model.GetModelObjectSelector().GetAllObjectsWithType(welds);
moe.SelectInstances = false;
return moe;
}