创建基本特征
NXOpen对于特征的创建和修改利用该特征对应的builder来进行,创建一个基本特征(比如长方体、球体等等)的步骤如下:
1.创建一个builder
2.设置bulider的各个属性
3.对builder进行'commit'
4.销毁builder
例如,我们要创建一个长方体:
import NXOpen import NXOpen.Features def main(): theSession = NXOpen.Session.GetSession() workPart = theSession.Parts.Work # 创建builder blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder( NXOpen.Features.Block.Null) # 类型-原点和边长 blockFeatureBuilder1.Type = NXOpen.Features.BlockFeatureBuilder.Types.OriginAndEdgeLengths # 布尔 blockFeatureBuilder1.BooleanType = NXOpen.Features.FeatureBooleanType.Create # 原点和边长参数 originPoint1 = NXOpen.Point3d(0.0, 0.0, 0.0) blockFeatureBuilder1.SetOriginAndLengths(originPoint1, "100", "100", "100") # commit block_feature = blockFeatureBuilder1.CommitFeature() blockFeatureBuilder1.Destroy() if __name__ == '__main__': main()
打开NX12.0,新建模型,alt+F8,选择文件,运行就能创建一个长方体