I'm only starting to use NX Open, and I have a general question regarding Block Styler.
I undertsand that we have visual tools to combine controls into a dialog, and then generate the skeleton code to which we add actual functionality. This seems to be quite clear - or so I think.
But what if we need to change something in the dialog box - change the layout, add/take away certain tools and the regenerate the code, which will revert it to the original blank state without any added custom lines.
I remember reading that Block Styler name derives from the fact that the dialog is made of 'blocks' which can be put together. Maybe it is possible to somehow utilize this and not regenerate the entire code over?
What is the best practice regarding making changes in dialog box? Whar do you typically do when you need to make such change?
Yes, its not a round-trip-programming and it is sometimes painful.
In all but the most simple programs I store the dlx and the generated code file(s) in a separate directory and use a copy of the code file(s) in my project. This prevents me from accidently overwriting my manually added code.
Changes can be integrated into the projects code by comparing and copying them from the new autogenerated code.
For complex dialogs I add a helper class that contains all the logic (initializing, handling callbacks etc.) and keep the dialog code itself as simple as possible.
For what it is worth..
I kinda of use the same approach as described by ijb. I however roughly sketch the GUI I want before doing anything and against my (very rough) program work flow and then I try to also list/include possible future option(s). These way possible future options have a block on the GUI and I simply hide them when displaying the GUI (or they do nothing!).
When I find the time to investigate/code the possible option I had in mind I then have the GUI all set up. Obviously if the GUI set up you had in mind a few weeks (months!) ago does not really work (say a list box would be better than a drop down list) then it's back to square one!
In the past we have used a text file comparison tool to quickly prot changes from the template code generated by NX and the working version with our modifications in.
The tool we use is Araxis Merge (http://www.araxis.com/merge/), it's not cheap, but it can do some awesome things.
However, we have now written a wrapper framework to handle this in Java. We can just throw away the generated code and use our own Java project templates. We still have to manually modify the code when adding/changing/removing blocks, but its so much simpler.
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX184.108.40.206 MP11 64bit] Testing: [NX220.127.116.11 MP1]
I am set up more or less the same as the others.
I use C++ for my API.
So after creating the Vis studio project for the "main" code, I create a sub folder "Dialog" and create the DLX and associated files there using the NX block styler GUI.
Then I COPY the dialog .CPP and .HPP to the "main" code file folder, add the copies to the project, and edit from there. (so the copies in the "Dialog" sub-folder are never edited, except thru the NX block styler GUI).
I use Winmerge (free from Sourceforge.net) to merge changes made thru the NX GUI into the "main" folder files.
I also try to keep most logic OUT of the functions created by the GUI - rather than 20 lines of code I just call a function, to minimize the differences in the GUI generated code.
Note after compile/link, you can run a .BAT to automatically copy the current DLX file (and DLL/exe file) to the area you want to run from for testing. This makes sure the DLX and DLL are consistant with each other.
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled
Don't know if you have a SNAP license, but, if you do, things are abit smoother. The Block Styler code generation process can (optionally) generate two files. You are only supposed to modify one of thse, and it will not get overwritten. The SNAP Getting Started Guide says:
When you save a dialog in Block UI Styler, two Visual Basic files are created containing template code. The idea is that you “fill in the blanks” in this template code to define the way you want your dialog to behave. Actually, using our example from above, you should only modify the code in the OrthoLines.vb file. As its name implies, the other generated file (OrthoLines.Private.vb) is “private”, and you are not supposed to edit it by hand. In fact, if you change the design of the dialog using Block UI Styler, saving the changes will overwrite the “private” file, so your handcrafted edits would be lost, anyway.
The contents of the VB files will depend on the options you chose in Block UI Styler. If you want to run your code from the Journal Editor, you should set “Generate Partial Classes” to False. This will force all the generated code to be placed in one file, which you can just open and execute from within the Journal Editor. If you generate two files (as described above), neither of them can be executed from within the Journal Editor.
For limited this problem, I use a "Partial Class". This class contain all custom code and I do just a relation between the classes generated by NX and my Class. My Partial Class contain so all functions that I need have.
In clear, I have 3 files:
When I need to modify my Block Styler, NX rewrite its Class File (example.vb) and its DLX (example.dlx ) but all my code is in my Class File (examplePartial.vb).
Just, I need add 6 code lines in the function New() in NX's Class File.
I add too 1 code line in the function initialize_cb() in NX's Class File.
Example in attachment file and video.