Print all open drawings

The following journal code will print all drawing sheets from all fully loaded part files to your default printer. This can be useful if you want some quick print outs for reference. It should use the default paper size for your printer. If it does not, or you prefer a different paper size, you can uncomment or add the appropriate paper size in the PrintSheet subroutine.

Creating Arcs, part 1

Creating Unassociative Arcs

In this tutorial, we'll look at creating unassociative arc objects. So, with all the whiz-bang technology in NX, why look at unassociative arcs? The answer is three-fold:

  • the creation methods are simple and straightforward
  • the methods will introduce other NX data structures
  • the geometry itself is perfectly valid and useful for modeling operations, title block geometry, logo art, etc

In short, the goal of this tutorial is to show you how to create useful geometry and introduce you to a few concepts that you will run into again when working with other NX object types.

The API offers three basic ways to create unassociative arcs:

  • through three specified points
  • with a given center point, orientation matrix, radius, start angle, and end angle
  • with a given center point, an X vector, a Y vector (together, the vectors will define the arc's orientation matrix), radius, start angle, and end angle

We'll take a look at each in turn.

Find Duplicate Sheet Bodies

Find Duplicate Sheet Bodies

It can be easy to duplicate geometry in a CAD file, especially when importing from 'neutral' formats such as IGES. The journal below helps to identify duplicate sheet bodies. It will scan through the sheet bodies in the work part looking for potential duplicates. It is intended to be used on sheet bodies comprised of a single face each (such as imported IGES geometry, when the 'automatic sew' option is not used). By default, the journal moves any potential duplicates to layer 255 (change this to your preference in the code before running the journal). I suggest inspecting them more closely before doing something more drastic such as deleting them out of the file. The method used to find duplicates is not 100% guaranteed; but most of the misidentified matches in my testing have been due to suspect input geometry (Garbage In - Garbage Out, as always).

Sort a list of NX objects

Sort a list of custom objects

The .NET List object is a great way to store a collection of related objects; objects can be added and retrieved easily and the List can quickly be converted to an array for NXOpen methods that require an array. The List object even has a .Sort method that works great with native data types (string, integer, double, etc). But, if you have ever wanted to sort a list of NX objects, such as drawing sheets by name, the default .Sort method may error out or give unexpected results. The good news is: there is an overloaded version of the .Sort method that allows you to specify exactly what to sort by and how. This is accomplished by writing a custom function that ranks the objects and telling the .Sort method to use the custom function.