[NXOpenC++]UG二次開発,SelectTaggedObjectよりUGオブジェクトを選択してtagラベルを出力する
説明:SelectTaggedObjectでUGオブジェクトを選択してtagラベルを出力します
テストコード:
効果:
テストコード:
// SelectTaggedObject tag
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include
# include
using std::ostrstream;
using std::endl;
using std::ends;
using std::cerr;
#else
# include
# include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace NXOpen;
using namespace std;
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char err[133],
msg[133];
sprintf(msg, "*** ERROR code %d at line %d in %s:
+++ ",
irc, line, file);
UF_get_fail_message(irc, err);
UF_print_syslog(msg, FALSE);
UF_print_syslog(err, FALSE);
UF_print_syslog("
", FALSE);
UF_print_syslog(call, FALSE);
UF_print_syslog(";
", FALSE);
if (!UF_UI_open_listing_window())
{
UF_UI_write_listing_window(msg);
UF_UI_write_listing_window(err);
UF_UI_write_listing_window("
");
UF_UI_write_listing_window(call);
UF_UI_write_listing_window(";
");
}
}
return(irc);
}
extern DllExport void ufsta( char *param, int *returnCode, int rlen )
{
/* Initialize the API environment */
if( UF_CALL(UF_initialize()) )
{
return;
}
/* TODO: Add your application code here */
Session *theSession = Session::GetSession();
Part *workPart(theSession->Parts()->Work());
UI *theUI = UI::GetUI();
TaggedObject *object;
Point3d cursor;
//
Selection::Response res;
res=theUI->SelectionManager()->SelectTaggedObject(" "," ",Selection::SelectionScopeWorkPart,true,false,&object,&cursor);
//SelectionScopeUseDefault
//SelectionScopeWorkPart
//SelectionScopeWorkPartAndOccurrence
if (res == Selection::ResponseObjectSelected)// = 5
{
uc1601(" ",1);
theSession->ListingWindow()->Open(); //
char tag[256]="";
sprintf(tag,"%d",object->GetTag()); // tag tag_t char
theSession->ListingWindow()->WriteLine(tag); //
}
if (res == Selection::ResponseObjectSelectedByName)// ,
{
uc1601("ObjectSelectedByName",1);
}
else if (res == Selection::ResponseCancel)//2
{
uc1601(" ",1);
}
else if(res == Selection::ResponseBack)//1
{
uc1601(" ",1);
}
else if(res == 3) //Selection::DialogResponseOk=2
{
uc1601(" ",1);
}
/* Terminate the API environment */
UF_CALL(UF_terminate());
}
extern int ufusr_ask_unload( void )
{
return (UF_UNLOAD_IMMEDIATELY);
}
効果: