Ehaviv
Computer
- Jul 2, 2003
- 1,012
Hi
Please can someone help in converting this python code to vb
Thank you very much
Please can someone help in converting this python code to vb
Thank you very much
Code:
def datum_plane(self, datum_origin, datum_normals, datum_corners):
self.theLw.WriteLine('\n')
self.theLw.WriteLine("Datum Plane function")
for i in range(len(datum_corners)):
datumPlaneBuilder = workPart.Features.CreateDatumPlaneBuilder(NXOpen.Features.Feature.Null)
self.theLw.WriteLine('\n')
self.theLw.WriteLine('\n')
self.theLw.WriteLine('\n')
#returns an NX.Open Plane object, from DatumPlaneBuilder class
plane = datumPlaneBuilder.GetPlane()
geom = []
plane.SetGeometry(geom)
plane.SetUpdateOption(NXOpen.SmartObject.UpdateOption.WithinModeling)
#using dist from plane to origin and a surface normal to create the plane
plane.SetMethod(NXOpen.PlaneTypes.MethodType.Coefficients)
origin = NXOpen.Point3d(datum_origin[i][0], datum_origin[i][1], datum_origin[i][2])
plane.Origin = origin
#a, b, c coefficients
normal = NXOpen.Vector3d(datum_normals[i][0], datum_normals[i][1], datum_normals[i][2])
plane.Normal = normal
plane.Evaluate()
datumPlaneBuilder.ResizeDuringUpdate=False
datum_feat=datumPlaneBuilder.CommitFeature()
#need to get journal Identifier of datum plane and pass it as an object
self.theLw.WriteLine("Datum feature is "+str(datum_feat.JournalIdentifier))
#create instance of resize plane
resizePlaneBuilder = workPart.Features.CreateResizePlaneBuilder(NXOpen.Features.Feature.Null)
datum_object = workPart.Datums.FindObject(str(datum_feat.JournalIdentifier))
resizePlaneBuilder.Plane.Value = datum_object
resizePlaneBuilder.ResizeDuringUpdate = False
corner_pts = [None] * 4
#multiplying by a scale factor just moves the planes further out
# to adjust size, recalculate your corner points
corner_pts[0] = NXOpen.Point3d(datum_corners[i][0][0],datum_corners[i][0][1],datum_corners[i][0][2])
corner_pts[1] = NXOpen.Point3d(datum_corners[i][1][0],datum_corners[i][1][1],datum_corners[i][1][2])
corner_pts[2] = NXOpen.Point3d(datum_corners[i][3][0],datum_corners[i][3][1],datum_corners[i][3][2])
corner_pts[3] = NXOpen.Point3d(datum_corners[i][2][0],datum_corners[i][2][1],datum_corners[i][2][2])
resizePlaneBuilder.SetCornerPoints(corner_pts)
resizePlaneBuilder.Commit()
resizePlaneBuilder.Destroy()
datumPlaneBuilder.Destroy()