If you open a new NX session in Gateway, start recording a journal, then create a new part, the recorded journal will contain everything you need.
(Hint: Session.Parts.FileNew() )
Note that this is the best way to figure out what part of the API you need for any future inquiries like this.
I think Session.Parts.FileNew() will allow you to create a new part, but it will not actually present the dialog.
For that you can use the wrapped equivalent of the Open C function:
Thank you Steve for your suggestion.
I am using your suggested code as follows,
NXOpen.UF.UFSession theUFSession = NXOpen.UF.UFSession.GetUFSession();
theUFSession.Ui.AskCreatePartFilename(ref partFileName, ref units, out response);
Using above code I was able to invoke "New Part File" dialog, but once I click 'OK' button I get 2 error message dialogs and NX crashes (in debug/release).
Please refer attached JPEG "Error.jpg" for the sequences of dialogs when NX crashes.
Also I want default "File->New" dialog to get invoked and not the "New Part File" dialog.
I want to invoke "File->New" dialog as it will allow my users to use any user defined templates from local machines as well as default templates in the "UGII_ROOT_DIR\\templates" folder Viz. model-plain-1-mm-template.prt.
(Thanks Jim, Yes using "Session.Parts.FileNew()" I was able to create new Part but It doesn't invoke the "File->New" dialog.)
How to invoke "File->New" menu from NX plug-in?
You are correct, the dialog that this function presents is not the same dialog that you see when you use File -> New in NX. Most of the dialogs that you see when running interactive NX are not available for use in custom programs - the few exceptions are things like class selection dialogs.
But the error that you got when using the wrapper function looks serious. Please create an incidient report with your local GTAC office so that we can investigate this thoroughly.
Thank you Steve.
I was giving relative filepath to the variable ‘partFileName’ the ‘AskCreatePartFilename(…)’. Once I set complete path it stopped crashing.
But it doesn’t solve my issue as I am still not getting valid “NXOpen.Part workPart”.
You will need to use the filename returned from that call, as well as the units chosen to create a new part. In VB, it looks like this:
Dim partUnits As NXOpen.Part.Units
ufs.Ui.AskCreatePartFilename(fileName, units, response)
If units.Equals(2) Then
partUnits = Part.Units.Inches
partUnits = Part.Units.Millimeters
Dim workPart As Part = theSession.Parts.NewDisplay(fileName, partUnits)
This may not be completely clear in the docs, but in the Open C docs for the original function, UF_UI_ask_create_part_filename, there is a link to a related function, UF_UI_ugmgr_ask_create_part_file_name , which has to following comments:
Thank you for your help. I was able to create new part using "theSession.Parts.NewDisplay" as you mentioned in your earlier post.
But it is created in Gateway ("File->Applications->Gateway" is selected).
Can I make it in 'File->Applications->Modeling' (Ctrl+M) using API? How?