import NXOpen import NXOpen.Features def CreateBall(x,y,z,l,w,h) : session = NXOpen.Session.GetSession() workPart = session.Parts.Work # 创建长方体生成器 blockBuilder = workPart.Features.CreateBlockFeatureBuilder(NXOpen.Features.Block.Null) # 设置长方体类型为“原点和边长” blockBuilder.Type = NXOpen.Features.BlockFeatureBuilder.Types.OriginAndEdgeLengths # 设置布尔操作类型 blockBuilder.BooleanType = NXOpen.Features.FeatureBooleanType.Create # 设置原点和边长 originPoint = NXOpen.Point3d(x,y,z) blockBuilder.SetOriginAndLengths(originPoint, l, w, h) # 提交特征并销毁生成器 blockFeature = blockBuilder.CommitFeature() blockBuilder.Destroy() if __name__ == '__main__': #需要传入长方体原点的x,y,z坐标,数值类型双精度 #需要传入长方体长宽高,数值为双精度 #example: #x=1.0 #y=1.0 #z=1.0 #l="1.0" #w="1.0" #h="1.0" x=None y=None z=None CreatePoint(x,y,z,l,w,h)