//==============================================================================
// WARNING!! This file is overwritten by the Block UI Styler while generating
// the automation code. Any modifications to this file will be lost after
// generating the code again.
//
// Filename: D:\NXopen\BaiduSyncdisk\studio\hkjm\ui\hkjm.cpp
//
// This file was generated by the NX Block UI Styler
// Created by: MiCH-CEO
// Version: NX 12
// Date: 08-06-2025 (Format: mm-dd-yyyy)
// Time: 19:18 (Format: hh-mm)
//
//==============================================================================
//==============================================================================
// Purpose: This TEMPLATE file contains C++ source to guide you in the
// construction of your Block application dialog. The generation of your
// dialog file (.dlx extension) is the first step towards dialog construction
// within NX. You must now create a NX Open application that
// utilizes this file (.dlx).
//
// The information in this file provides you with the following:
//
// 1. Help on how to load and display your Block UI Styler dialog in NX
// using APIs provided in NXOpen.BlockStyler namespace
// 2. The empty callback methods (stubs) associated with your dialog items
// have also been placed in this file. These empty methods have been
// created simply to start you along with your coding requirements.
// The method name, argument list and possible return values have already
// been provided for you.
//==============================================================================
//------------------------------------------------------------------------------
//These includes are needed for the following template code
//------------------------------------------------------------------------------
#include "hkjm.hpp"
using namespace NXOpen;
using namespace NXOpen::BlockStyler;
//------------------------------------------------------------------------------
// Initialize static variables
//------------------------------------------------------------------------------
Session *(hkjm::theSession) = NULL;
UI *(hkjm::theUI) = NULL;
//------------------------------------------------------------------------------
// Constructor for NX Styler class
//------------------------------------------------------------------------------
hkjm::hkjm()
{
try
{
// Initialize the NX Open C++ API environment
hkjm::theSession = NXOpen::Session::GetSession();
hkjm::theUI = UI::GetUI();
theDlxFileName = "hkjm.dlx";
theDialog = hkjm::theUI->CreateDialog(theDlxFileName);
// Registration of callback functions
theDialog->AddApplyHandler(make_callback(this, &hkjm::apply_cb));
theDialog->AddOkHandler(make_callback(this, &hkjm::ok_cb));
theDialog->AddUpdateHandler(make_callback(this, &hkjm::update_cb));
theDialog->AddInitializeHandler(make_callback(this, &hkjm::initialize_cb));
theDialog->AddDialogShownHandler(make_callback(this, &hkjm::dialogShown_cb));
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
throw;
}
}
//------------------------------------------------------------------------------
// Destructor for NX Styler class
//------------------------------------------------------------------------------
hkjm::~hkjm()
{
if (theDialog != NULL)
{
delete theDialog;
theDialog = NULL;
}
}
//------------------------------- DIALOG LAUNCHING ---------------------------------
//
// Before invoking this application one needs to open any part/empty part in NX
// because of the behavior of the blocks.
//
// Make sure the dlx file is in one of the following locations:
// 1.) From where NX session is launched
// 2.) $UGII_USER_DIR/application
// 3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly
// recommended. This variable is set to a full directory path to a file
// containing a list of root directories for all custom applications.
// e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_BASE_DIR\ugii\menus\custom_dirs.dat
//
// You can create the dialog using one of the following way:
//
// 1. USER EXIT
//
// 1) Create the Shared Library -- Refer "Block UI Styler programmer's guide"
// 2) Invoke the Shared Library through File->Execute->NX Open menu.
//
//------------------------------------------------------------------------------
extern "C" DllExport void ufusr(char *param, int *retcod, int param_len)
{
hkjm *thehkjm = NULL;
try
{
UF_initialize(); //开发的许可函数,初始化
thehkjm = new hkjm();
// The following method shows the dialog immediately
thehkjm->Show();
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
hkjm::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
if(thehkjm != NULL)
{
delete thehkjm;
thehkjm = NULL;
}UF_terminate(); //释放许可函数,结束化
}
//------------------------------------------------------------------------------
// This method specifies how a shared image is unloaded from memory
// within NX. This method gives you the capability to unload an
// internal NX Open application or user exit from NX. Specify any
// one of the three constants as a return value to determine the type
// of unload to perform:
//
//
// Immediately : unload the library as soon as the automation program has completed
// Explicitly : unload the library from the "Unload Shared Image" dialog
// AtTermination : unload the library when the NX session terminates
//
//
// NOTE: A program which associates NX Open applications with the menubar
// MUST NOT use this option since it will UNLOAD your NX Open application image
// from the menubar.
//------------------------------------------------------------------------------
extern "C" DllExport int ufusr_ask_unload()
{
//return (int)Session::LibraryUnloadOptionExplicitly;
return (int)Session::LibraryUnloadOptionImmediately;
//return (int)Session::LibraryUnloadOptionAtTermination;
}
//------------------------------------------------------------------------------
// Following method cleanup any housekeeping chores that may be needed.
// This method is automatically called by NX.
//------------------------------------------------------------------------------
extern "C" DllExport void ufusr_cleanup(void)
{
try
{
//---- Enter your callback code here -----
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
hkjm::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
}
int hkjm::Show()
{
try
{
theDialog->Show();
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
hkjm::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return 0;
}
//------------------------------------------------------------------------------
//---------------------Block UI Styler Callback Functions--------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//Callback Name: initialize_cb
//------------------------------------------------------------------------------
void hkjm::initialize_cb()
{
try
{
group0 = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group0"));
hk2edge = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()->FindBlock("hk2edge"));
hk1edge = dynamic_cast<NXOpen::BlockStyler::CurveCollector*>(theDialog->TopBlock()->FindBlock("hk1edge"));
hk1sd = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()->FindBlock("hk1sd"));
hk2sd = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()->FindBlock("hk2sd"));
group = dynamic_cast<NXOpen::BlockStyler::Group*>(theDialog->TopBlock()->FindBlock("group"));
hkdj = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()->FindBlock("hkdj"));
hk2jd = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()->FindBlock("hk2jd"));
hk1jd = dynamic_cast<NXOpen::BlockStyler::ExpressionBlock*>(theDialog->TopBlock()->FindBlock("hk1jd"));
vector0 = dynamic_cast<NXOpen::BlockStyler::SpecifyVector*>(theDialog->TopBlock()->FindBlock("vector0"));
bodySelect0 = dynamic_cast<NXOpen::BlockStyler::BodyCollector*>(theDialog->TopBlock()->FindBlock("bodySelect0"));
color1 = dynamic_cast<NXOpen::BlockStyler::ObjectColorPicker*>(theDialog->TopBlock()->FindBlock("color1"));
color2 = dynamic_cast<NXOpen::BlockStyler::ObjectColorPicker*>(theDialog->TopBlock()->FindBlock("color2"));
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
hkjm::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
}
//获取实体、、
// 过滤函数:获取工作部件的所有可见实体
std::vector<tag_t> FilterVisibleBodies()
{
std::vector<tag_t> visibleBodies;
NXOpen::Session* theSession = NXOpen::Session::GetSession();
NXOpen::UI* theUI = NXOpen::UI::GetUI();
try {
// 获取工作部件
NXOpen::Part* workPart = theSession->Parts()->Work();
if (!workPart) {
theUI->NXMessageBox()->Show("错误提示", NXOpen::NXMessageBox::DialogTypeError, "未找到工作部件!");
return visibleBodies;
}
// 获取工作部件的tag
tag_t workPartTag = workPart->Tag();
// 遍历工作部件中的所有实体
tag_t currentBody = NULL_TAG;
UF_OBJ_cycle_objs_in_part(workPartTag, UF_solid_type, ¤tBody);
while (currentBody != NULL_TAG)
{
// 获取实体的显示属性
UF_OBJ_disp_props_t disp_props;
if (UF_OBJ_ask_display_properties(currentBody, &disp_props) == 0)
{
// 检查实体是否可见(未隐藏)
if (disp_props.blank_status == UF_OBJ_NOT_BLANKED)
{
// 检查实体所在层是否可见
int layer_status = 0;
UF_LAYER_ask_status(disp_props.layer, &layer_status);
// 只添加可见层(工作层、活动层、参考层)的实体
if (layer_status == UF_LAYER_WORK_LAYER ||
layer_status == UF_LAYER_ACTIVE_LAYER ||
layer_status == UF_LAYER_REFERENCE_LAYER)
{
visibleBodies.push_back(currentBody);
}
}
}
// 获取下一个实体
UF_OBJ_cycle_objs_in_part(workPartTag, UF_solid_type, ¤tBody);
}
// 如果没有可见实体,显示提示信息
if (visibleBodies.empty()) {
theUI->NXMessageBox()->Show("提示", NXOpen::NXMessageBox::DialogTypeInformation, "工作部件中没有可见实体!");
}
}
catch (const std::exception& ex) {
theUI->NXMessageBox()->Show("过滤错误", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return visibleBodies;
}
//------------------------------------------------------------------------------
//Callback Name: dialogShown_cb
//This callback is executed just before the dialog launch. Thus any value set
//here will take precedence and dialog will be launched showing that value.
//------------------------------------------------------------------------------
// 修改dialogShown_cb函数
void hkjm::dialogShown_cb()
{
try {
// 获取所有可见实体的tag
std::vector<tag_t> visibleBodyTags = FilterVisibleBodies();
// 转换为NXOpen::Body对象 - 使用正确的方法
std::vector<NXOpen::Body*> visibleBodies;
for (tag_t tag : visibleBodyTags) {
// 正确方法:使用NXObjectManager::Get获取对象后动态转换
NXOpen::NXObject* obj = NXOpen::NXObjectManager::Get(tag);
if (obj) {
// 使用安全的dynamic_cast进行类型转换
NXOpen::Body* body = dynamic_cast<NXOpen::Body*>(obj);
if (body) {
visibleBodies.push_back(body);
}
}
}
// 设置到bodySelect0控件
if (bodySelect0 && !visibleBodies.empty()) {
// 获取控件的属性列表
NXOpen::BlockStyler::PropertyList* props = bodySelect0->GetProperties();
// 创建正确的TaggedObject数组
std::vector<NXOpen::TaggedObject*> selectedObjects;
for (NXOpen::Body* body : visibleBodies) {
// Body继承自TaggedObject,直接转换
selectedObjects.push_back(static_cast<NXOpen::TaggedObject*>(body));
}
// 设置选中对象 - 使用正确的属性名
props->SetTaggedObjectVector("SelectedObjects", selectedObjects);
// 不需要调用SetProperties,设置后自动生效
// 刷新控件 - 使用正确的方法
bodySelect0->Update();
}
}
catch (std::exception& ex) {
hkjm::theUI->NXMessageBox()->Show("对话框错误", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
}
//------------------------------------------------------------------------------
//Callback Name: apply_cb
//------------------------------------------------------------------------------
// 应用按钮回调函数 - 读取所有控件数据
//------------------------------------------------------------------------------
int hkjm::apply_cb()
{
int errorCode = 0; // 错误代码,0表示成功
try
{
// 获取NX会话和工作部件
NXOpen::Session* theSession = NXOpen::Session::GetSession();
NXOpen::Part* workPart = theSession->Parts()->Work();
NXOpen::UI* theUI = NXOpen::UI::GetUI();
// ===== 1. 处理曲线选择器1的值 =====
std::vector<NXOpen::Curve*> sectionCurves1;
if (hk1edge)
{
// 使用智能指针管理属性列表内存
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(hk1edge->GetProperties());
std::vector<NXOpen::TaggedObject*> selObjs = props->GetTaggedObjectVector("SelectedObjects");
for (NXOpen::TaggedObject* obj : selObjs) {
if (NXOpen::Curve* curve = dynamic_cast<NXOpen::Curve*>(obj)) {
sectionCurves1.push_back(curve);
}
}
}
// ===== 2. 处理曲线选择器2的值 =====
std::vector<NXOpen::Curve*> sectionCurves2;
if (hk2edge)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(hk2edge->GetProperties());
std::vector<NXOpen::TaggedObject*> selObjs = props->GetTaggedObjectVector("SelectedObjects");
for (NXOpen::TaggedObject* obj : selObjs) {
if (NXOpen::Curve* curve = dynamic_cast<NXOpen::Curve*>(obj)) {
sectionCurves2.push_back(curve);
}
}
}
// ===== 3. 获取hk1sd表达式值 =====
double hk1sdValue = 0.0;
if (hk1sd)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(hk1sd->GetProperties());
hk1sdValue = props->GetDouble("Value");
}
// ===== 4. 获取hk2sd表达式值 =====
double hk2sdValue = 0.0;
if (hk2sd)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(hk2sd->GetProperties());
hk2sdValue = props->GetDouble("Value");
}
// ===== 5. 获取hkdj表达式值 =====
double hkdjValue = 0.0;
if (hkdj)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(hkdj->GetProperties());
hkdjValue = props->GetDouble("Value");
}
// ===== 6. 获取hk1jd表达式值 =====
double hk1jdValue = 0.0;
if (hk1jd)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(hk1jd->GetProperties());
hk1jdValue = props->GetDouble("Value");
}
// ===== 7. 获取hk2jd表达式值 =====
double hk2jdValue = 0.0;
if (hk2jd)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(hk2jd->GetProperties());
hk2jdValue = props->GetDouble("Value");
}
// ===== 8. 获取矢量方向 =====
NXOpen::Vector3d directionVec(0.0, 0.0, 1.0); // 默认Z轴
if (vector0)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(vector0->GetProperties());
directionVec = props->GetVector("Vector");
}
// ===== 9. 处理选中的实体 =====
std::vector<NXOpen::Body*> selectedBodies;
if (bodySelect0)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(bodySelect0->GetProperties());
std::vector<NXOpen::TaggedObject*> selObjs = props->GetTaggedObjectVector("SelectedObjects");
for (NXOpen::TaggedObject* obj : selObjs) {
if (NXOpen::Body* body = dynamic_cast<NXOpen::Body*>(obj)) {
selectedBodies.push_back(body);
}
}
}
// ===== 10. 获取颜色选择器1的颜色 =====
int colorIndex1 = 0;
if (color1)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> colorProps(color1->GetProperties());
std::vector<int> colors = colorProps->GetIntegerVector("Value");
if (!colors.empty()) colorIndex1 = colors[0];
}
// ===== 11. 获取颜色选择器2的颜色 =====
int colorIndex2 = 0;
if (color2)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> colorProps(color2->GetProperties());
std::vector<int> colors = colorProps->GetIntegerVector("Value");
if (!colors.empty()) colorIndex2 = colors[0];
}
// ===== 3. 创建拉伸特征 =====
if (!sectionCurves1.empty() && hk1sdValue != 0.0)
{
// 设置撤销标记
NXOpen::Session::UndoMarkId markId = theSession->SetUndoMark(
NXOpen::Session::MarkVisibilityVisible, "拉伸操作");
// 创建拉伸构建器
NXOpen::Features::ExtrudeBuilder* extrudeBuilder =
workPart->Features()->CreateExtrudeBuilder(nullptr);
// 创建截面
NXOpen::Section* section = workPart->Sections()->CreateSection(
0.001, 0.001, 0.05);
extrudeBuilder->SetSection(section);
// 创建曲线规则 - 使用dumb规则
std::vector<NXOpen::SelectionIntentRule*> rules;
if (!sectionCurves1.empty())
{
// 创建dumb曲线规则 - 直接传递曲线向量
NXOpen::SelectionIntentRule* curveRule =
workPart->ScRuleFactory()->CreateRuleCurveDumb(sectionCurves1);
rules.push_back(curveRule);
}
// 获取帮助点(曲线中点)- 使用UF_CURVE_ask_centroid获取曲线中心点
NXOpen::Point3d helpPoint(0.0, 0.0, 0.0);
if (!sectionCurves1.empty())
{
double centroid[3] = { 0.0, 0.0, 0.0 };
// 使用UF函数获取曲线中心点
if (UF_CURVE_ask_centroid(sectionCurves1[0]->Tag(), centroid) == 0)
{
helpPoint = NXOpen::Point3d(centroid[0], centroid[1], centroid[2]);
}
else
{
// 如果获取中心点失败,使用曲线端点作为备选
tag_t curveTag = sectionCurves1[0]->Tag();
double twoEnd[2][3] = { {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0} };
// 使用UF_EVAL系列函数获取曲线端点
UF_EVAL_p_t evaluator = NULL;
double limits[2];
// 初始化评估器
if (UF_EVAL_initialize(curveTag, &evaluator) == 0)
{
// 获取参数范围
if (UF_EVAL_ask_limits(evaluator, limits) == 0)
{
// 确保参数范围有序
if (limits[0] > limits[1])
{
double temp = limits[0];
limits[0] = limits[1];
limits[1] = temp;
}
// 评估起点
if (UF_EVAL_evaluate(evaluator, 0, limits[0], twoEnd[0], NULL) == 0)
{
helpPoint = NXOpen::Point3d(twoEnd[0][0], twoEnd[0][1], twoEnd[0][2]);
}
// 如果起点评估失败,尝试评估终点
else if (UF_EVAL_evaluate(evaluator, 0, limits[1], twoEnd[1], NULL) == 0)
{
helpPoint = NXOpen::Point3d(twoEnd[1][0], twoEnd[1][1], twoEnd[1][2]);
}
}
// 释放评估器资源
UF_EVAL_free(evaluator);
}
// 如果所有方法都失败,使用原点
if (helpPoint.X == 0.0 && helpPoint.Y == 0.0 && helpPoint.Z == 0.0)
{
// 记录错误信息
char msg[256];
sprintf_s(msg, "无法获取曲线 %d 上的点", curveTag);
hkjm::theUI->NXMessageBox()->Show("警告",
NXOpen::NXMessageBox::DialogTypeWarning,
msg);
}
}
}
// 添加到截面 - 使用正确的API签名
section->AddToSection(
rules, // 规则向量
sectionCurves1[0], // 种子曲线
NULL, // 起始连接对象(无)
NULL, // 结束连接对象(无)
helpPoint, // 帮助点
NXOpen::Section::ModeCreate // 创建模式
);
// 设置拉伸方向 - 使用正确的CreateDirection重载
NXOpen::Point3d origin(0.0, 0.0, 0.0);
NXOpen::Direction* extrudeDirection =
workPart->Directions()->CreateDirection(
origin,
directionVec,
NXOpen::SmartObject::UpdateOptionWithinModeling
);
extrudeBuilder->SetDirection(extrudeDirection);
// 设置拉伸范围
NXOpen::GeometricUtilities::Limits* limits = extrudeBuilder->Limits();
limits->StartExtend()->Value()->SetRightHandSide(std::to_string(hk1sdValue).c_str()); // 起始距离设为hk1sdValue
limits->EndExtend()->Value()->SetRightHandSide("0"); // 结束距离设为0
// ===== 添加拔模角度设置 =====
if (hk1jdValue != 0.0) // 只有拔模角度不为0时才设置
{
// 设置拔模类型:从起始位置简单拔模
extrudeBuilder->Draft()->SetDraftOption(
NXOpen::GeometricUtilities::SimpleDraft::SimpleDraftTypeSimpleFromStart);
// 设置前拔模角度(从截面开始处拔模)
extrudeBuilder->Draft()->FrontDraftAngle()->SetRightHandSide(
std::to_string(hk1jdValue).c_str());
// 设置后拔模角度(这里我们设为0,因为只需要单边拔模)
extrudeBuilder->Draft()->BackDraftAngle()->SetRightHandSide("0");
}
//// 设置布尔操作类型(创建新实体)
//extrudeBuilder->BooleanOperation()->SetType(
// NXOpen::GeometricUtilities::BooleanOperation::BooleanTypeCreate);
// 设置布尔操作类型(求差)
extrudeBuilder->BooleanOperation()->SetType(
NXOpen::GeometricUtilities::BooleanOperation::BooleanTypeSubtract);
// 设置求差目标体
if (!selectedBodies.empty()) {
extrudeBuilder->BooleanOperation()->SetTargetBodies(selectedBodies);
}
else {
// 如果没有选择目标体,显示警告信息
theUI->NXMessageBox()->Show("警告",
NXOpen::NXMessageBox::DialogTypeWarning,
"未选择求差目标体,将创建独立特征");
}
// 在执行拉伸操作前记录目标体的面
std::map<tag_t, std::set<tag_t>> bodyFacesBeforeMap;
for (NXOpen::Body* body : selectedBodies) {
std::set<tag_t> faceTags;
std::vector<NXOpen::Face*> faces = body->GetFaces();
for (NXOpen::Face* face : faces) {
faceTags.insert(face->Tag());
}
bodyFacesBeforeMap[body->Tag()] = faceTags;
}
// 执行拉伸操作
NXOpen::NXObject* featureNXObject = extrudeBuilder->Commit();
NXOpen::Features::Feature* feature =
dynamic_cast<NXOpen::Features::Feature*>(featureNXObject);
// 收集新创建的面
std::vector<NXOpen::Face*> newFaces;
// 方法1:比较特征创建前后的面差异
for (NXOpen::Body* body : selectedBodies) {
std::vector<NXOpen::Face*> facesAfter = body->GetFaces();
std::set<tag_t> faceTagsBefore = bodyFacesBeforeMap[body->Tag()];
for (NXOpen::Face* face : facesAfter) {
tag_t faceTag = face->Tag();
// 如果这个面在创建前不存在,则是新面
if (faceTagsBefore.find(faceTag) == faceTagsBefore.end()) {
newFaces.push_back(face);
}
}
}
// 仅给新面设置颜色
if (colorIndex1 > 0 && !newFaces.empty()) {
for (NXOpen::Face* face : newFaces) {
tag_t faceTag = face->Tag();
UF_OBJ_set_color(faceTag, colorIndex1);
UF_DISP_set_highlight(faceTag, 0);
}
// 刷新显示
theSession->Parts()->Work()->Views()->WorkView()->UpdateDisplay();
}
// 清理资源
extrudeBuilder->Destroy();
section->Destroy();
}
}
catch (std::exception& ex)
{
errorCode = 1;
hkjm::theUI->NXMessageBox()->Show("错误",
NXOpen::NXMessageBox::DialogTypeError,
ex.what());
}
catch (...)
{
errorCode = 1;
hkjm::theUI->NXMessageBox()->Show("错误",
NXOpen::NXMessageBox::DialogTypeError,
"未知错误");
}
return errorCode;
}
//------------------------------------------------------------------------------
//Callback Name: update_cb
//------------------------------------------------------------------------------
int hkjm::update_cb(NXOpen::BlockStyler::UIBlock* block)
{
try
{
if(block == hk2edge)
{
//---------Enter your code here-----------
}
else if(block == hk1edge)
{
//---------Enter your code here-----------
}
else if(block == hk1sd)
{
//---------Enter your code here-----------
}
else if(block == hk2sd)
{
//---------Enter your code here-----------
}
else if(block == hkdj)
{
//---------Enter your code here-----------
}
else if(block == hk2jd)
{
//---------Enter your code here-----------
}
else if(block == hk1jd)
{
//---------Enter your code here-----------
}
else if(block == vector0)
{
//---------Enter your code here-----------
}
else if(block == bodySelect0)
{
//---------Enter your code here-----------
}
else if(block == color1)
{
//---------Enter your code here-----------
}
else if(block == color2)
{
//---------Enter your code here-----------
}
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
hkjm::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return 0;
}
//------------------------------------------------------------------------------
//Callback Name: ok_cb
//------------------------------------------------------------------------------
int hkjm::ok_cb()
{
int errorCode = 0;
try
{
errorCode = apply_cb();
}
catch(exception& ex)
{
//---- Enter your exception handling code here -----
errorCode = 1;
hkjm::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
}
return errorCode;
}
//------------------------------------------------------------------------------
//Function Name: GetBlockProperties
//Description: Returns the propertylist of the specified BlockID
//------------------------------------------------------------------------------
PropertyList* hkjm::GetBlockProperties(const char *blockID)
{
return theDialog->GetBlockProperties(blockID);
}
报错:严重性 代码 说明 项目 文件 行 禁止显示状态
错误(活动) E0135 class "NXOpen::BlockStyler::BodyCollector" 没有成员 "Update" hkjm D:\NXopen\BaiduSyncdisk\studio\hkjm\hkjm.cpp 320
错误(活动) E0144 "NXOpen::TaggedObject *" 类型的值不能用于初始化 "NXOpen::NXObject *" 类型的实体 hkjm D:\NXopen\BaiduSyncdisk\studio\hkjm\hkjm.cpp 292
错误 C2440 “初始化”: 无法从“NXOpen::TaggedObject *”转换为“NXOpen::NXObject *” hkjm D:\NXopen\BaiduSyncdisk\studio\hkjm\hkjm.cpp 292
错误 C2039 "Update": 不是 "NXOpen::BlockStyler::BodyCollector" 的成员 hkjm D:\NXopen\BaiduSyncdisk\studio\hkjm\hkjm.cpp 320
最新发布