PLM之家-NX9.0二次开发实例 26 NX Open C++获取装配所有组件(1) ...
抄了站长发的视频代码,但是在NX10.0上运行就会出错,一直找不出问题所在,求大神打救,,,:'(第一次运行出现>>执行函数时捕捉到异常:,,,,,,函数名:ufusr
第二次运行出现如下错误:>>NX10已停止工作>>出现了一个问题.导致程序停止正常工作.如果有可用的解决方案.Window将关闭程序并通知你.
代码如下:
//------------------------------------------------------------------------------------------------------------------
static void do_NXOpenCpp()
{
Session *theSession = Session::GetSession();
ListingWindow *lw = theSession->ListingWindow();
lw->Open();
BasePart *baseworkpart = theSession->Parts()->BaseWork();
BasePart *basedisplaypart = theSession->Parts()->BaseDisplay();
Assemblies::ComponentAssembly*componentAssembly=baseworkpart->ComponentAssembly();
Assemblies::Component *rootcomponent = componentAssembly->RootComponent();
if ( rootcomponent==NULL)
{
lw->WriteLine("This is not an assembly structure!\n");
}
else
{
std::vector<Assemblies::Component *>children = rootcomponent->GetChildren();
for(int i=0; i<children.size(); i++)
{
Assemblies::Component *component=children;
lw->WriteLine(component->DisplayName()+"\n");
}
}
}
//------------------------------------------------------------------------------------------------------------------
自己顶一下,求打救啊,,,,:'( 解决了,原来是VS平台太低了,换VS2012就可以了
页:
[1]