C++
NXOpen::Session::Parts()
returns an NXOpen::PartCollection
, which, like all NX Open collections, can be iterated over, and the iterator can be dereferenced to access the actual Part
object:
#include <NXOpen/Session.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/BasePart.hxx>
NXOpen::Session *session = NXOpen::Session::GetSession();
for (auto it = session->Parts()->begin(); it != session->Parts()->end(); it++)
{
NXOpen::Part *part = *it;
std::string name = part->Name().GetText();
std::string fullPath = part->FullPath().GetText();
// Do something with name or fullPath...
}
C#
Simply looping over NXOpen.Session.Parts
will do the trick:
using NXOpen.Session;
using NXOpen.Part;
Session session = Session.GetSession();
foreach (Part part in session.Parts)
{
string name = part.Name;
string fullPath = part.FullPath;
// Do something with name or fullPath...
}
Java
import nxopen.Session;
import nxopen.Part;
import java.util.Iterator;
Session session = (Session)SessionFactory.get("Session");
for (Iterator it = session.parts().iterator(); it.hasNext();) {
Part part = (Part)it.next();
String name = part.name();
String fullPath = part.fullPath();
// Do something with name or fullPath...
}