之前讲到过用UF相关函数创建圆柱体,这里再讲一种用builder创建圆柱体的方法,代码如下,结合了UF函数,在工作坐标系下创建该圆柱体
import NXOpen
import NXOpen.Features
import NXOpen.GeometricUtilities
import NXOpen.UF as UF
ufsession=UF.UFSession.GetUFSession()
session=NXOpen.Session.GetSession()
workpart=session.Parts.Work
cylinderbuilder=workpart.Features.CreateCylinderBuilder(NXOpen.Features.Cylinder.Null)
cylinderbuilder.Type=NXOpen.Features.CylinderBuilder.Types. AxisDiameterAndHeight
cylinderbuilder.BooleanOption.Type=NXOpen.GeometricUtilities.BooleanOperationBooleanType.Create
cylinderbuilder.Diameter.Value=200.0
cylinderbuilder.Height.Value=400.0
[x1,y1,z1]=ufsession.Csys.MapPoint(3,[0.0,0.0,0.0],2)
cylinderbuilder.Direction=NXOpen.Vector3d(0.0,0.0,1.0)
cylinderbuilder.Origin=NXOpen.Point3d(x1,y1,z1)
cylinderbuilder.CommitFeature()
cylinderbuilder.Destroy()