Cancel
Showing results for 
Search instead for 
Did you mean: 

Part name from Terminating object

Creator
Creator

Hi, 

I am searching for vb code or function that will return the part number and name(from assembly navigator) from annotation terminating object (Edge, surface etc).

 

Thanks in advance

1 REPLY

Re: Part name from Terminating object

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter

Hello,

 

I'm not too familiar with VB, but you should be able to get the info out of my c++ code.

 

//------------------------------------------------------------------------------
// Selection any objects
//------------------------------------------------------------------------------
std::vector< NXOpen::TaggedObject * > MyClass::select_any_objects()
{
	NXString message("Select any objects:");
	NXString title("Select objects");
	Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
	bool include_features = 0;	
	bool keep_highlighted = 0;
	std::vector< NXOpen::TaggedObject * > objectArray;

	// Select any object array
	Selection::Response res = selmgr->SelectTaggedObjects(
			message, title, scope, include_features, 
			keep_highlighted, objectArray );

	return objectArray;
}

//------------------------------------------------------------------------------
// Do something
//------------------------------------------------------------------------------
void MyClass::do_it()
{
	std::vector< NXOpen::TaggedObject * > any_objs = select_any_objects();

	for (auto item:any_objs)
	{
		NXOpen::NXObject * object = dynamic_cast<NXOpen::NXObject *>(item);
		print(object->OwningComponent()->Name());
	}
	
}

First i cast my selected item to a NXObject, then use this function

documentation

 

This gives you access to this, which this class :

component class

 

Where you can get the name.