NX Journal Open drawing
2019/11/30 categories:NX Journal| tags:NX Journal|VB|Python|
I wrote a program to open a drawing from Teamcenter. I think it can be used for batch processing of drawings.
Python Code
import NXOpen
def main():
theSession = NXOpen.Session.GetSession()
openPart(theSession, "drawingName")
def openPart(theSession, drawingName):
try:
part1 = theSession.Parts.FindObject(drawingName)
theSession.Parts.SetDisplay(part1, False, True)
except Exception as e:
theSession.Parts.SetNonmasterSeedPartData(drawingName)
status1 = theSession.Parts.OpenBaseDisplay(drawingName)
if __name__ == '__main__':
main()
VB Code
Option Strict Off
Imports System
Imports NXOpen
Module module1
Dim s As Session = Session.GetSession()
Sub Main()
OpenDrawing("drawingName")
End Sub
Sub OpenDrawing(drawingName)
Dim partName As String
partName = "drawingName"
Dim theSession As Session = Session.GetSession()
theSession.Parts.SetNonmasterSeedPartData(partName)
Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus
basePart1 = theSession.Parts.OpenBaseDisplay(partName, partLoadStatus1)
partLoadStatus1.Dispose()
End Sub
End Module