NXOpen之使用Python实现尺寸盒功能

NXOpen之使用Python实现尺寸盒功能

import math
import NXOpen
import NXOpen.UF

def BoundingBox() : 

    theSession  = NXOpen.Session.GetSession()
    theUFSession = NXOpen.UF.UFSession.GetUFSession()
    workPart = theSession.Parts.Work
    
    size = theSession.ListingWindow
    size.Open()
    size.WriteLine("Bounding Boxes:")

    NULLTAG = 0

    all_bodies = workPart.Bodies
    bounding_Box_Coords = []

    for body in all_bodies:
        bounding_Box_Coords = theUFSession.ModlGeneral.AskBoundingBox(body.Tag) 

        size.WriteLine(str(bounding_Box_Coords[0]) + "  ")
        size.WriteLine(str(bounding_Box_Coords[1]) + "  ")
        size.WriteLine(str(bounding_Box_Coords[2]) + "  ")
        size.WriteLine(str(bounding_Box_Coords[3]) + "  ")
        size.WriteLine(str(bounding_Box_Coords[4]) + "  ")
        size.WriteLine(str(bounding_Box_Coords[5]))
        size.WriteLine("  ")

    
if __name__ == '__main__':
    BoundingBox()

你可能感兴趣的:(Python,NXOpen)