Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NXOpen -- Stp214Importer Error

Status
Not open for further replies.

lharrison

New member
Oct 19, 2011
52
Hello all,
I'm trying to write what I thought would be a quick and easy NXOpen program to batch STP->NX conversions. We wanted a few other things such as changing part and background color that the translation tool doesn't provide. I'm having quite an issue trying to use the NXOpen methods to convert these files though. Here's a snippet of code where the conversion is supposed to take place:

Code:
Session NXSession = Session.GetSession();

            foreach (string s in (e.Argument as ListBox).Items)
            {
                try
                {
                    Step214Importer STPImporter = NXSession.DexManager.CreateStep214Importer();
                    STPImporter.InputFile = s;
                    STPImporter.ImportTo = Step214Importer.ImportToOption.WorkPart;
                    STPImporter.ImportToTeamcenter = false;
                    STPImporter.LayerDefault = 1;
                    STPImporter.ObjectTypes.Curves = true;
                    STPImporter.ObjectTypes.Surfaces = true;
                    STPImporter.ObjectTypes.Solids = true;
                    STPImporter.ObjectTypes.Csys = true;
                    STPImporter.ObjectTypes.ProductData = true;
                    STPImporter.ObjectTypes.PmiData = true;
                    STPImporter.Optimize = true;
                    STPImporter.SettingsFile = @"C:\Program Files\Siemens\NX 9.0\step214ug\step214ug.def";
                    STPImporter.FileOpenFlag = false;
                    NXObject _object = STPImporter.Commit();
                    STPImporter.Destroy();
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

Problem is, I'm not getting any output at all from the translator. Once the command window pops open, I'm greeted with the following message:
Code:
Error - Unhandled UG Exception caught.
With the following message <Internal error: memory access violation>.
Please reference syslog for more detailed information

referring to the syslog, I see the section indicating my NXOpen program has begun, and the final message simply states that the translation has failed. I can easily convert models using the translator from the command line as well as from the NX GUI. Is this piece of NXOpen broken in my release(9.0.2)?
 
Replies continue below

Recommended for you

lharrison said:
We wanted a few other things such as changing part and background color...

I'd suggest modifying the seed part settings; then any parts you convert will use your settings. The seed parts can be found in the {NX install directory}\STEP214UG folder:
[ul][li]step214ugnullnx90_in.prt[/li]
[li]step214ugnullnx90_mm.prt[/li][/ul]

www.nxjournaling.com
 
We've modified the seed parts, but I'm not sure how to go about setting the default color of the imported part. There aren't any bodies within the seed part, so nothing I can set the display properties on. The background color was easy though. I should also note the original question is part of a larger workflow for converting parts and setting some company standard settings, thus the reason I went towards NXOpen rather than the translator.

Bruce
 
In Preferences -> Object, you can set default colors for solid and sheet bodies, and other object types. I realize my previous answer (and this one so far) doesn't solve the overall problem, but I thought modifying the seed file would be useful for you. All your translations will use your preferred defaults, not just the ones handled through your converter code.

Back to the larger problem: the code snippet looks pretty good from what I can tell, but the error message is much too vague to be very useful. I'd start by double checking that the step files for processing and the settings file exist before starting the translation.

Also, the step214Importer has a .Validate method, you might try checking that before calling the .Commit method.

The code will try to import each step file into the current work part, is that intentional? or should each step file get imported into its own part?

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor