Worldscope

Details panel of the part navigator in NX

Palavras-chave:

Publicado em: 16/08/2025

Understanding the Details Panel in NX Part Navigator

The NX Part Navigator is a crucial tool for managing the structure and features of a part within Siemens NX. The Details panel, often located at the bottom of the Part Navigator window, provides contextual information about the currently selected object. This article explores the functionality and programmatic access to the Details panel, focusing on how developers can leverage this information to enhance their NX applications.

Fundamental Concepts / Prerequisites

To effectively understand and work with the Details panel in the NX Part Navigator, familiarity with the following concepts is essential:

  • NX Open API: The NX Open API provides programmatic access to NX functionality. A working knowledge of C, C++, or Java, and the basics of NX Open is required.
  • Part Navigator: Understanding the structure and organization of the Part Navigator.
  • NX Objects: Familiarity with common NX objects like Features, Bodies, Datums, and Sketches.
  • NX Sessions: Knowing how to access the current NX session is vital for most NX Open applications.

Accessing Details Panel Information via NX Open

While directly modifying the content or presentation of the Details Panel programmatically is not usually the intention (Siemens controls this), we can leverage NX Open API to inspect the properties displayed within the details panel for the selected object. This allows creating NX Open applications that react to the selected object and its properties.


#include <NXOpen/Session.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/DisplayableObject.hxx>
#include <NXOpen/Assemblies_Component.hxx>


using namespace NXOpen;

extern "C" DllExport int ufusr(UF_CALLING_MODULE_TABLE_t *param, int *retcod, int rlen)
{
    Session *theSession = Session::GetSession();
    UI *theUI = UI::GetUI();
    Part *workPart = theSession->Parts()->Work();

    if (workPart == nullptr)
    {
        theUI->NXMessageBox()->Show("Error", NXOpen::NXMessageBox::DialogType::Error, "No Work Part is active.");
        *retcod = 1;
        return 0;
    }

    try
    {
        DisplayableObject* selectedObject = theUI->SelectionManager()->GetSelectedObject(0);

        if (selectedObject != nullptr)
        {
            std::string objectType = selectedObject->GetType().c_str();
            std::string objectName = selectedObject->Get জিজ্ঞেস().c_str(); //Name of the NX Object
            std::string message = "Selected Object Type: " + objectType + "\n";
            message += "Selected Object Name: " + objectName;

            //Example to see if object is component
            if (objectType == "Assemblies::Component")
            {
                Assemblies::Component * component = dynamic_cast<Assemblies::Component*>(selectedObject);
                Part * componentPart = component->GetPart();
                if (componentPart != nullptr)
                {
                     message += "\n Component Part Name: " + componentPart->Name().c_str();
                }
            }
            theUI->NXMessageBox()->Show("Object Information", NXOpen::NXMessageBox::DialogType::Information, message.c_str());
        }
        else
        {
             theUI->NXMessageBox()->Show("Information", NXOpen::NXMessageBox::DialogType::Information, "No object selected in the Part Navigator.");
        }
    }
    catch (NXException& ex)
    {
        theUI->NXMessageBox()->Show("Error", NXOpen::NXMessageBox::DialogType::Error, ex.Message().c_str());
        *retcod = 1;
        return 0;
    }

    *retcod = 0;
    return 0;
}

Code Explanation

The C++ code snippet demonstrates how to retrieve information about the object selected in the NX Part Navigator. Here's a breakdown:

First, the code obtains pointers to the NX Session, UI and Part objects. It checks to see if a part is currently active.

The `theUI->SelectionManager()->GetSelectedObject(0)` line retrieves the first selected object in the UI. If an object is selected, its type and name are extracted using `GetType()` and `Get জিজ্ঞেস()` respectively and shown in a message box. The code then checks to see if the object is a component, if it is it obtains the part name and displays it in the message box.

If no object is selected or if an error occurs, an appropriate message box is displayed using `theUI->NXMessageBox()`.

Complexity Analysis

The time complexity of this code snippet is primarily determined by the `GetSelectedObject()` and the object type check. `GetSelectedObject()` generally has a complexity of O(1), as it directly accesses the currently selected object. The additional operations like `GetType()` and `Get ถาม()` depend on the underlying implementation within NX Open but are expected to be relatively fast (close to O(1)).

The space complexity is also relatively low. The code mainly stores pointers and strings, resulting in a space complexity of O(1) with respect to the size of the part file.

Alternative Approaches

While the above code directly uses the `SelectionManager`, another approach involves iterating through the entire Part Navigator tree. This is generally inefficient for simply retrieving the selected object, but it becomes necessary if you need to analyze the relationships between various objects in the navigator. Iterating through the entire tree can have a time complexity of O(N), where N is the number of nodes in the Part Navigator, and is therefore not recommended unless absolutely necessary. Additionally, other NX Open functions exist for specific properties. If, for example, you needed the feature parameters you would use the appropriate class calls for that feature type to obtain the values.

Conclusion

The Details panel in the NX Part Navigator provides valuable context for understanding and interacting with part features. While direct modification of the panel's contents is typically not possible, NX Open API enables developers to access the properties displayed. By leveraging the `SelectionManager` and understanding the structure of NX objects, developers can create custom NX applications that respond intelligently to user selections and access critical part information.