点击查看详细介绍

获取实提质心UF_CALL(UF_MODL_ask_mass_props_3d

西尔贝 10年前 4278 2

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


求解释,,这个函数的第一个参数到底是哪个Tag,运行结果老是错,感觉这句话没用上一样?

#include <stdio.h>

#include "afx.h"

#include <iostream>

#include <uf.h>

#include "uf_part.h"

#include <uf_attr.h>

#include <uf_ui.h>

#include <uf_obj.h>

#include "uf_modl.h"

#include "uf_weight.h"

#include "uf_modl_types.h "

using namespace std;

#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))

static int report( char *file, int line, char *call, int irc)

{

if (irc)

{

char messg[133];

printf("%s, line %d: %s\n", file, line, call);

(UF_get_fail_message(irc, messg)) ?

printf(" returned a %d\n", irc) :

printf(" returned error %d: %s\n", irc, messg);

}

return(irc);

}

int main()

{

int nRetCode = 0;

int rcode;

CString partName = "e:\\a.prt"; //此处为创建block的全路径名

tag_t partTag = NULL_TAG;

tag_t attrTag = NULL_TAG;

tag_t obj1 = NULL_TAG;

UF_PART_load_status_t error_status;

// initialize UG and print and error on failure

rcode = UF_initialize();

if ( rcode )

{

// TODO: change error code to suit your needs

cerr << _T("Fatal Error: UG initialization failed") << endl;

nRetCode = 1;

}

else

{

// TODO: code your application's behavior here.

//把部件载入内存

UF_PART_open_quiet((char *)(LPCTSTR) partName,

&partTag,

&error_status);

//得到对象标识

UF_OBJ_cycle_objs_in_part( partTag, UF_feature_type, &obj1 );

//使用这个函数把部件做为工作部件

double acc_value[11];

double mass_props[47];

double statistics[13];

UF_CALL(UF_MODL_ask_mass_props_3d(&obj1,1,1,3,1,2,acc_value,mass_props,statistics));

double masscenter[3]={

mass_props[3]*10,

mass_props[4]*10,

mass_props[5]*10};

cout << "质心x="<<masscenter[0]<< endl;

cout << "质心y="<<mass_props[4]<< endl;

cout << "质心z="<<mass_props[5]<< endl;

cout << "密度="<<mass_props[46]<< endl;

UF_terminate();

}

return nRetCode;

}

1

最新回复 (2)
  • 狙击兴 VIP会员 7年前
    1

    你没有导入对象,obj是空的

  • 大艺术家 4年前
    2

    加判断,去调试,断点

请登录后发表新帖