Skip to content

Commit f09bb5c

Browse files
committed
Hellow world examples
1 parent 4a64780 commit f09bb5c

File tree

8 files changed

+96
-0
lines changed

8 files changed

+96
-0
lines changed

Examples/ex0001.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ex0001.py
2+
import NXOpen.UF
3+
4+
def main():
5+
NXOpen.UF.UFSession.GetUFSession().Ui.DisplayMessage("Hello World!", 1)
6+
7+
if __name__ == '__main__':
8+
main()

Examples/ex0002.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ex0002.py
2+
import NXOpen
3+
4+
def main():
5+
listing_window = NXOpen.Session.GetSession().ListingWindow
6+
7+
listing_window.Open()
8+
listing_window.WriteFullline("Hello world!")
9+
listing_window.Close()
10+
11+
if __name__ == '__main__':
12+
main()

Pictures/pic1_NX_developer_tab.png

-3.03 KB
Loading

Pictures/pic4_NX_message_box.PNG

4.13 KB
Loading

Pictures/pic5_NX_run_code.png

9.42 KB
Loading

Pictures/pic6_NX_Journal_Manager.PNG

7.97 KB
Loading
5.61 KB
Loading

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,80 @@ or press "<kbd>Ctrl</kbd> + 2" keyboard shortcut. Then in the `User Interface Pr
3737
<img src=".\\Pictures\\pic3_NX_change_language_python.png" width="500">
3838
<figcaption>Fig.3 - Change the Journal Language to Python.</figcaption>
3939
</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>
40116
</pre>

0 commit comments

Comments
 (0)