Hello everyone!
After having written some small NX Journals in .vb during the past years, I've now come to the conclusion that it might be a good move to give Python a try. So I've started to learn Python (looks quite sympathetic to me!) and then I took one of the simpler .vb Journals of mine as an example to try and create the same functionality using Python. After some hours I managed to arrange the 30 lines of code in the proper order and it's working as expected.
Next, I'd like to see wheter I can use simple dialogue boxes as I used to in .vb utilizing System.Windows.Forms or NXOpenUI. I don't wish to go for BlockStyler right now because I am afraid to run into comlicated requirements - I'd prefer to keep things easy and straightforward - at least for a start.
System.Windows.Forms seems to be impossible as it is .NET related and there are quite a few GUI packages for Python like wxPython which does not yet fully support Python 3.3. Do I get that correct? Or is there a tweak?
So I thought NXOpenUI would rescue me and I tried:
import NXOpenUI
but that give an ImportError: No module named 'NXOpenUI'.
OK, next I tried:
import NXOpen.UI
which raises a weird error message referring to a line number which doesn't exist, still the sum of it is "ImporError: NXOpen.UI".
Feels as if there is no such thing as NXOpenUI ?
Well, I thought, it's about time for RTFM, so I went into NX Help / Programming tools, where an internet based page opens up "Accessing the Programming Tools help", telling me to "click here". Next, I can click Product area NX Open / NX Open for Python / NX Open Python Reference Guide.
My naive expectation was to get a .chm file for download, instead I am led to a web based page with API reference for NXOpen Python. This looks very pleasing at the 1st glance, but if I try to use the index, it becomes quite confusing being displayed in two columns, and it displays very slow.
To speed up things, I tried using the "quick search" feature feeding it some simple phrases like "OpenUI" or "Input" but after some minutes waiting for results, all I get for results are hundreds of lines saying
"blabla Class: {"timestamp":1491981571724,"status":404,"error":"Not Found","message":"No message available","path":"/data_services//resources/nx/11/nx_api/custom/en_US/nxopen_python_ref/_sources/NXOpen.Features.MapleBuilder.txt"}...
So now here come a few newbee questions:
- Is it possible at all to use either NXOpenUI or System.Windows.Forms dialogue boxes for Python in NX? And if so: how can this be done?
- What is your experience in making use of the NX Open Python API Reference 11.0 documentation? What is the best practice to cope with it?
- What other sources of information and orientation would you recommend to get things running?
Thank for your support & my best Regards to everyone,
UdoMM
Python comments
The Python API is (relatively) new, and it's not used by many people (compared to VB), so it has a few rough edges and it's much harder to get help.
You can't use Windows forms with Python (not without some significant trickery, anyway). But, as you say, there are other GUI tools available.
The Python help is not a CHM file because CHM is an inherently Windows technology, and Python is not.
Writing code by trial-and-error is going to be a slow and painful exercise. Look at the Python examples that ship with NX, or the ones on the GTAC site.
open source NXOpen Python documentation and tutorials
I have decided to document some of my experiences with NXOpen Python API here on GitHub
https://github.com/Foadsf/NXOpen_Python_tutorials
I encourage all other to contribute so we have a place accumulate knowledge.
Lead Mechanical Engineer @ VDL ETG T&D / ASML
Twitter
NX Discord