@@ -37,4 +37,80 @@ or press "<kbd>Ctrl</kbd> + 2" keyboard shortcut. Then in the `User Interface Pr
37
37
<img src =" .\\Pictures\\pic3_NX_change_language_python.png " width =" 500 " >
38
38
<figcaption >Fig.3 - Change the Journal Language to Python.</figcaption >
39
39
</center >
40
+ </pre >
41
+
42
+
43
+ ### Hello world!
44
+
45
+ Let's start with a very simple "Hello World!" example where a Message windows will show a text message (i.e., ` string ` ).
46
+
47
+ ``` Python
48
+ # ex0001.py
49
+ import NXOpen.UF
50
+
51
+ def main ():
52
+ NXOpen.UF .UFSession.GetUFSession().Ui.DisplayMessage(" Hello World!" , 1 )
53
+
54
+ if __name__ == ' __main__' :
55
+ main()
56
+ ```
57
+
58
+ to run the code you need to go to the ` Developer ` tab and find the ` Play ` button:
59
+
60
+ <pre >
61
+ <center >
62
+ <img src =" .\\Pictures\\pic5_NX_run_code.png " width =" 500 " >
63
+ <figcaption >Fig.4 - Find the Play button.</figcaption >
64
+ </center >
65
+ </pre >
66
+
67
+ In the ` Journal Manager ` panel you can ` Browse ` to find and run the code:
68
+
69
+
70
+
71
+ <pre >
72
+ <center >
73
+ <img src =" .\\Pictures\\pic6_NX_Journal_Manager.png " width =" 500 " >
74
+ <figcaption >Fig.5 - Find the Play button.</figcaption >
75
+ </center >
76
+ </pre >
77
+
78
+ The result will be as the picture below:
79
+
80
+ <pre >
81
+ <center >
82
+ <img src =" .\\Pictures\\pic4_NX_message_box.png " width =" 500 " >
83
+ <figcaption >Fig.6 - Message box window.</figcaption >
84
+ </center >
85
+ </pre >
86
+
87
+
88
+
89
+ The message box window is good for alerting the using of specific issues, however the texts are not searchable or selectable. Alternatively, we could use:
90
+
91
+
92
+ ``` Python
93
+ # ex0002.py
94
+ import NXOpen
95
+
96
+ def main ():
97
+ listing_window = NXOpen.Session.GetSession().ListingWindow
98
+
99
+ listing_window.Open()
100
+ listing_window.WriteFullline(" Hello world!" )
101
+ listing_window.Close()
102
+
103
+ if __name__ == ' __main__' :
104
+ main()
105
+ ```
106
+
107
+ and the result must be
108
+
109
+ pic6_NX_information_window
110
+
111
+ <pre >
112
+ <center >
113
+ <img src =" .\\Pictures\\pic6_NX_information_window.png " width =" 500 " >
114
+ <figcaption >Fig.6 - Information box window.</figcaption >
115
+ </center >
40
116
</pre >
0 commit comments