TEKLA C# 选择模型中所有焊缝的最快方法是什么

利用选择功能

 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;
        }

 

posted @ 2024-06-30 20:37  南胜NanSheng  阅读(45)  评论(0编辑  收藏  举报