Showing results for 
Search instead for 
Do you mean 
Reply

Hello NX World!

[ Edited ]

something like this may already be included in the documentation, just wanted to share it

#import standard NX Open libraries
import NXOpen
import NXOpen.BlockStyler
import NXOpen.Features
#included libraries
import random
import math


#define your class
class generic_class:
        # Constructor for NX Styler class
    # ------------------------------------------------------------------------------
    def __init__(self):
        
        # class members
        self.theSession = None
        self.theUI = None
        self.theLw= None
        self.theDialogName = ""
        self.theDialog = None
        #Get the UF session
        self.theUfSession = None

       

        try:
            self.theSession = NXOpen.Session.GetSession()
            self.theUI = NXOpen.UI.GetUI()
            self.theLw = self.theSession.ListingWindow #create print window
            self.theUfSession = NXOpen.UF.UFSession.GetUFSession() 
            
        except Exception as ex:
            # ---- Enter your exception handling code here -----
            raise ex
#define the class method def hello_world(self): #open the console self.theLw.Open() self.theLw.WriteLine("Hello NX World!") def main(): try: #create instance of class myclass = generic_class()
#call the method myclass.hello_world() except Exception as ex: # ---- Enter your exception handling code here ----- NXOpen.UI.GetUI().NXMessageBox.Show("Block Styler", NXOpen.NXMessageBox.DialogType.Error, str(ex)) if __name__ == "__main__": main()