30 lines
925 B
Python
30 lines
925 B
Python
import NXOpen
|
|
import NXOpen.Features
|
|
def CreateBall(x,y,z,d) :
|
|
session = NXOpen.Session.GetSession()
|
|
workPart = session.Parts.Work
|
|
# 创建球体生成器
|
|
sphereBuilder = workPart.Features.CreateSphereBuilder(NXOpen.Features.Sphere.Null)
|
|
|
|
# 设置球体参数
|
|
sphereBuilder.Type = NXOpen.Features.SphereBuilder.Types.CenterPointAndDiameter
|
|
sphereBuilder.Diameter.Value = d # 设置直径
|
|
centerPoint = workPart.Points.CreatePoint(NXOpen.Point3d(x,y,z)) # 创建球心
|
|
sphereBuilder.CenterPoint = centerPoint
|
|
|
|
# 提交特征并销毁生成器
|
|
sphereFeature = sphereBuilder.CommitFeature()
|
|
sphereBuilder.Destroy()
|
|
|
|
if __name__ == '__main__':
|
|
#需要传入球的球心点的x,y,z坐标,数值类型双精度
|
|
#需要传入球的直径D,数值为双精度
|
|
#example:
|
|
#x=1.0
|
|
#y=1.0
|
|
#z=1.0
|
|
#d=1.0
|
|
x=None
|
|
y=None
|
|
z=None
|
|
CreatePoint(x,y,z,d) |