我正在学习NX二次开发,用的是Visual Studio 2019,ug版本是12.0,开发平台是c++,uf函数为主nxopen函数为辅。需要你辅助我开发,重点注意开发模版是c++,优先使用uf函数,要求你先搞清楚你提供给我的代码真实有效性,语句与标点符号的正确位置,避免出现ug12.0没有提供的接口成员出现!确保所有方法调用都符合 NX12 的 API 签名,深度思考下再回答,每次回答前先回顾下前面的所有对话避免问题重复出现,每行代码都用中文注解具体意思与作用。
int qiaowei_tool::apply_cb()
{
int errorCode = 0; // 错误代码,0表示成功
NXOpen::Body* firstExtrudeBody = nullptr;// 将声明移到函数作用域
try
{
// 获取NX会话和工作部件
NXOpen::Session* theSession = NXOpen::Session::GetSession();
NXOpen::Part* workPart = theSession->Parts()->Work();
NXOpen::UI* theUI = NXOpen::UI::GetUI();
// ===== 1. 获取边界边曲线 =====
std::vector<NXOpen::Curve*> boundaryCurves;
if (bianjie_edge)
{
// 获取曲线选择器属性列表
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(bianjie_edge->GetProperties());
// 获取选中的对象集合
std::vector<NXOpen::TaggedObject*> selObjs = props->GetTaggedObjectVector("SelectedObjects");
// 遍历选中对象并转换为曲线
for (NXOpen::TaggedObject* obj : selObjs) {
if (NXOpen::Curve* curve = dynamic_cast<NXOpen::Curve*>(obj)) {
boundaryCurves.push_back(curve);
}
}
}
// ===== 2. 获取出料边曲线 =====
std::vector<NXOpen::Curve*> dischargeCurves;
if (chuliao_edge)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(chuliao_edge->GetProperties());
std::vector<NXOpen::TaggedObject*> selObjs = props->GetTaggedObjectVector("SelectedObjects");
for (NXOpen::TaggedObject* obj : selObjs) {
if (NXOpen::Curve* curve = dynamic_cast<NXOpen::Curve*>(obj)) {
dischargeCurves.push_back(curve);
}
}
}
// ===== 3. 获取出料沉桥值 =====
double materialThickness = 0.0;
if (expression_clcq)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(expression_clcq->GetProperties());
// 获取表达式数值
materialThickness = props->GetDouble("Value");
}
// ===== 4. 获取上模厚度值 =====
double scanHeight = 0.0;
if (expression_smh)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(expression_smh->GetProperties());
scanHeight = props->GetDouble("Value");
}
// ===== 5. 获取进料沉桥值 =====
double clearanceValue = 0.0;
if (expression_jlcq)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(expression_jlcq->GetProperties());
clearanceValue = props->GetDouble("Value");
}
// ===== 6. 获取倒桥角度值 =====
double currentAngle = 0.0;
if (expression_dqjiaodu)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(expression_dqjiaodu->GetProperties());
currentAngle = props->GetDouble("Value");
}
// ===== 7. 获取倒角开关状态 =====
bool chamferToggle = false;
if (toggle_daojiao)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(toggle_daojiao->GetProperties());
// 获取开关状态(选中/未选中)
chamferToggle = props->GetLogical("Value");
}
// ===== 8. 获取倒角半径值 =====
double chamferRadius = 0.0;
if (expression_rjiao && chamferToggle) // 仅在倒角开启时获取
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(expression_rjiao->GetProperties());
chamferRadius = props->GetDouble("Value");
}
// ===== 9. 获取偏移开关状态 =====
bool offsetToggle = false;
if (toggle_pianzhi)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(toggle_pianzhi->GetProperties());
offsetToggle = props->GetLogical("Value");
}
// ===== 10. 获取偏移距离值 =====
double offsetDistance = 0.0;
if (expression_pianzhi && offsetToggle) // 仅在偏移开启时获取
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(expression_pianzhi->GetProperties());
offsetDistance = props->GetDouble("Value");
}
// ===== 11. 获取矢量方向 =====
NXOpen::Vector3d directionVector(0.0, 0.0, 1.0); // 默认Z轴方向
if (vector0)
{
std::unique_ptr<NXOpen::BlockStyler::PropertyList> props(vector0->GetProperties());
// 获取用户指定的矢量方向
directionVector = props->GetVector("Vector");
}
// ===== 12. 验证必要输入 =====
if (boundaryCurves.size() < 2) {
throw std::runtime_error("需要选择两条桥位边界曲线!");
}
if (dischargeCurves.empty()) {
throw std::runtime_error("出料边曲线未选择!");
}
if (scanHeight <= 0) {
throw std::runtime_error("上模厚度必须大于0!");
}
// ===== 13. 计算两条边界曲线端点间的最短距离并创建两条连接直线 =====
tag_t line1Tag = NULL_TAG;
tag_t line2Tag = NULL_TAG;
double minDist = 0.0;
double remainingDist = 0.0;
try {
// 获取前两条边界曲线
NXOpen::Curve* curve1 = boundaryCurves[0];
NXOpen::Curve* curve2 = boundaryCurves[1];
// 获取曲线端点
double curve1Start[3] = { 0.0 }, curve1End[3] = { 0.0 };
double curve2Start[3] = { 0.0 }, curve2End[3] = { 0.0 };
// 获取曲线1端点
UF_EVAL_p_t evaluator1 = NULL;
if (UF_EVAL_initialize(curve1->Tag(), &evaluator1) != 0) {
throw std::runtime_error("无法初始化曲线1的评估器");
}
double limits1[2];
if (UF_EVAL_ask_limits(evaluator1, limits1) != 0) {
UF_EVAL_free(evaluator1);
throw std::runtime_error("无法获取曲线1的参数范围");
}
if (limits1[0] > limits1[1]) std::swap(limits1[0], limits1[1]);
if (UF_EVAL_evaluate(evaluator1, 0, limits1[0], curve1Start, NULL) != 0 ||
UF_EVAL_evaluate(evaluator1, 0, limits1[1], curve1End, NULL) != 0) {
UF_EVAL_free(evaluator1);
throw std::runtime_error("无法评估曲线1的端点");
}
UF_EVAL_free(evaluator1);
// 获取曲线2端点
UF_EVAL_p_t evaluator2 = NULL;
if (UF_EVAL_initialize(curve2->Tag(), &evaluator2) != 0) {
throw std::runtime_error("无法初始化曲线2的评估器");
}
double limits2[2];
if (UF_EVAL_ask_limits(evaluator2, limits2) != 0) {
UF_EVAL_free(evaluator2);
throw std::runtime_error("无法获取曲线2的参数范围");
}
if (limits2[0] > limits2[1]) std::swap(limits2[0], limits2[1]);
if (UF_EVAL_evaluate(evaluator2, 0, limits2[0], curve2Start, NULL) != 0 ||
UF_EVAL_evaluate(evaluator2, 0, limits2[1], curve2End, NULL) != 0) {
UF_EVAL_free(evaluator2);
throw std::runtime_error("无法评估曲线2的端点");
}
UF_EVAL_free(evaluator2);
// 转换为NXOpen点对象
NXOpen::Point3d p1_start(curve1Start[0], curve1Start[1], curve1Start[2]);
NXOpen::Point3d p1_end(curve1End[0], curve1End[1], curve1End[2]);
NXOpen::Point3d p2_start(curve2Start[0], curve2Start[1], curve2Start[2]);
NXOpen::Point3d p2_end(curve2End[0], curve2End[1], curve2End[2]);
// 计算两点间距离的函数
auto distance = [](const NXOpen::Point3d& a, const NXOpen::Point3d& b) -> double {
return sqrt(pow(a.X - b.X, 2) + pow(a.Y - b.Y, 2) + pow(a.Z - b.Z, 2));
};
// 计算四种可能的端点组合距离
double dist1 = distance(p1_start, p2_start);
double dist2 = distance(p1_start, p2_end);
double dist3 = distance(p1_end, p2_start);
double dist4 = distance(p1_end, p2_end);
// 找出最小距离对应的点对
minDist = std::min({ dist1, dist2, dist3, dist4 });
NXOpen::Point3d minPoint1, minPoint2;
int minIndex = 0;
if (minDist == dist1) {
minPoint1 = p1_start; minPoint2 = p2_start;
}
else if (minDist == dist2) {
minPoint1 = p1_start; minPoint2 = p2_end;
}
else if (minDist == dist3) {
minPoint1 = p1_end; minPoint2 = p2_start;
}
else {
minPoint1 = p1_end; minPoint2 = p2_end;
}
// 确定剩余的两个端点
auto isPointEqual = [](const NXOpen::Point3d& a, const NXOpen::Point3d& b, double tol = 1e-6) -> bool {
return (fabs(a.X - b.X) < tol) && (fabs(a.Y - b.Y) < tol) && (fabs(a.Z - b.Z) < tol);
};
NXOpen::Point3d remainingPoint1 = isPointEqual(minPoint1, p1_start) ? p1_end : p1_start;
NXOpen::Point3d remainingPoint2 = isPointEqual(minPoint2, p2_start) ? p2_end : p2_start;
remainingDist = distance(remainingPoint1, remainingPoint2);
// ===== 创建两条连接直线 =====
// 创建第一条直线(最短距离连接)
UF_CURVE_line_t line1Coords;
line1Coords.start_point[0] = minPoint1.X;
line1Coords.start_point[1] = minPoint1.Y;
line1Coords.start_point[2] = minPoint1.Z;
line1Coords.end_point[0] = minPoint2.X;
line1Coords.end_point[1] = minPoint2.Y;
line1Coords.end_point[2] = minPoint2.Z;
if (UF_CURVE_create_line(&line1Coords, &line1Tag) != 0 || line1Tag == NULL_TAG) {
throw std::runtime_error("创建最短距离直线失败");
}
// 设置第一条直线属性
int workLayer = workPart->Layers()->WorkLayer();
UF_OBJ_set_layer(line1Tag, 254);
// 创建第二条直线(剩余端点连接)
UF_CURVE_line_t line2Coords;
line2Coords.start_point[0] = remainingPoint1.X;
line2Coords.start_point[1] = remainingPoint1.Y;
line2Coords.start_point[2] = remainingPoint1.Z;
line2Coords.end_point[0] = remainingPoint2.X;
line2Coords.end_point[1] = remainingPoint2.Y;
line2Coords.end_point[2] = remainingPoint2.Z;
if (UF_CURVE_create_line(&line2Coords, &line2Tag) != 0 || line2Tag == NULL_TAG) {
throw std::runtime_error("创建剩余端点直线失败");
}
// 设置第二条直线属性
UF_OBJ_set_layer(line2Tag, 254);
UF_LAYER_set_status(254, UF_LAYER_INACTIVE_LAYER);
// 更新显示
UF_DISP_refresh();
// 显示成功信息
char msg[256];
snprintf(msg, sizeof(msg),
"已创建两条连接直线:\n"
"1. 最短距离直线: %.2f mm\n"
"2. 剩余端点直线: %.2f mm",
minDist, remainingDist);
theUI->NXMessageBox()->Show("操作成功",
NXOpen::NXMessageBox::DialogTypeInformation, msg);
}
catch (std::exception& ex) {
char errMsg[256];
snprintf(errMsg, sizeof(errMsg), "端点距离计算或直线创建失败: %s", ex.what());
theUI->NXMessageBox()->Show("错误",
NXOpen::NXMessageBox::DialogTypeError, errMsg);
errorCode = 2;
return errorCode; // 提前返回,不再继续后续操作
}
// ===== 14. 创建拉伸特征(新建体) =====
try {
// 设置撤销标记
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);
// 准备截面曲线:边界曲线 + 连接直线
std::vector<NXOpen::Curve*> sectionCurves;
sectionCurves.push_back(boundaryCurves[0]);
sectionCurves.push_back(boundaryCurves[1]);
// 将直线标签转换为曲线对象
NXOpen::Curve* line1Curve = dynamic_cast<NXOpen::Curve*>(
NXOpen::NXObjectManager::Get(line1Tag));
NXOpen::Curve* line2Curve = dynamic_cast<NXOpen::Curve*>(
NXOpen::NXObjectManager::Get(line2Tag));
if (line1Curve) sectionCurves.push_back(line1Curve);
if (line2Curve) sectionCurves.push_back(line2Curve);
// 创建曲线规则
std::vector<NXOpen::SelectionIntentRule*> rules;
if (!sectionCurves.empty()) {
NXOpen::SelectionIntentRule* curveRule =
workPart->ScRuleFactory()->CreateRuleCurveDumb(sectionCurves);
rules.push_back(curveRule);
}
// 获取帮助点(中点)
NXOpen::Point3d helpPoint(0.0, 0.0, 0.0);
if (!sectionCurves.empty()) {
tag_t curveTag = sectionCurves[0]->Tag();
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]) std::swap(limits[0], limits[1]);
double midParam = (limits[0] + limits[1]) / 2.0;
double midPoint[3];
if (UF_EVAL_evaluate(evaluator, 0, midParam, midPoint, NULL) == 0) {
helpPoint = NXOpen::Point3d(midPoint[0], midPoint[1], midPoint[2]);
}
}
UF_EVAL_free(evaluator);
}
}
// 添加到截面
section->AddToSection(
rules,
sectionCurves[0],
NULL,
NULL,
helpPoint,
NXOpen::Section::ModeCreate
);
// 设置拉伸方向
NXOpen::Point3d origin(0.0, 0.0, 0.0);
NXOpen::Direction* extrudeDirection =
workPart->Directions()->CreateDirection(
origin,
directionVector,
NXOpen::SmartObject::UpdateOptionWithinModeling
);
extrudeBuilder->SetDirection(extrudeDirection);
// 设置拉伸范围
NXOpen::GeometricUtilities::Limits* limitsObj = extrudeBuilder->Limits();
limitsObj->StartExtend()->Value()->SetRightHandSide(
std::to_string(materialThickness).c_str());
double endDistance = scanHeight - clearanceValue;
limitsObj->EndExtend()->Value()->SetRightHandSide(
std::to_string(endDistance).c_str());
// ===== 设置布尔操作为新建体 =====
extrudeBuilder->BooleanOperation()->SetType(
NXOpen::GeometricUtilities::BooleanOperation::BooleanTypeCreate);
// ===== 执行拉伸操作 =====
try {
// 提交拉伸操作
NXOpen::NXObject* featureNXObject = extrudeBuilder->Commit();
// 将特征对象转换为Extrude类型
NXOpen::Features::Extrude* extrudeFeature =
dynamic_cast<NXOpen::Features::Extrude*>(featureNXObject);
if (extrudeFeature) {
// 正确获取拉伸创建的实体
std::vector<NXOpen::Body*> resultBodies = extrudeFeature->GetBodies();
// 保存第一个实体(用于后续求差)
if (!resultBodies.empty()) {
firstExtrudeBody = resultBodies[0]; // 赋值给函数作用域的变量
}
// 显示结果信息
char successMsg[256];
if (!resultBodies.empty()) {
snprintf(successMsg, sizeof(successMsg),
"创建新实体成功!\n实体数量: %d\n起始距离: %.2f mm\n结束距离: %.2f mm",
resultBodies.size(), materialThickness, endDistance);
}
else {
snprintf(successMsg, sizeof(successMsg),
"拉伸操作完成但未创建实体!\n起始距离: %.2f mm\n结束距离: %.2f mm",
materialThickness, endDistance);
}
theUI->NXMessageBox()->Show("操作结果",
NXOpen::NXMessageBox::DialogTypeInformation, successMsg);
}
else {
throw std::runtime_error("创建的特征不是拉伸类型");
}
// 清理资源
extrudeBuilder->Destroy();
section->Destroy();
}
catch (std::exception& ex) {
// 拉伸操作错误处理
char errMsg[256];
snprintf(errMsg, sizeof(errMsg), "拉伸操作失败: %s", ex.what());
theUI->NXMessageBox()->Show("错误",
NXOpen::NXMessageBox::DialogTypeError, errMsg);
errorCode = 3;
// 特殊错误处理:布尔操作冲突
if (std::string(ex.what()).find("boolean") != std::string::npos) {
theUI->NXMessageBox()->Show("布尔操作错误",
NXOpen::NXMessageBox::DialogTypeError,
"请检查布尔操作设置是否与现有几何冲突");
errorCode = 4;
}
// 确保资源被清理
if (extrudeBuilder) extrudeBuilder->Destroy();
if (section) section->Destroy();
}
}
catch (std::exception& ex) {
// 外层异常处理
char errMsg[256];
snprintf(errMsg, sizeof(errMsg), "拉伸特征创建过程出错: %s", ex.what());
theUI->NXMessageBox()->Show("错误",
NXOpen::NXMessageBox::DialogTypeError, errMsg);
errorCode = 5;
}
// ===== 在拉伸操作成功后添加出料边曲线处理 =====
try {
// 设置撤销标记
NXOpen::Session::UndoMarkId curveMarkId = theSession->SetUndoMark(
NXOpen::Session::MarkVisibilityVisible, "出料边曲线长度编辑");
// 定义存储所有延伸曲线的向量(用于后续拉伸操作)
std::vector<NXOpen::Curve*> extendedCurves;
// 遍历所有出料边曲线
for (NXOpen::Curve* dischargeCurve : dischargeCurves) {
// 创建截面对象(用于曲线长度特征)
NXOpen::Section* section = workPart->Sections()->CreateSection(0.00095, 0.001, 0.05);
// 创建曲线长度构建器(用于延伸曲线)
NXOpen::Features::CurveLengthBuilder* curveLengthBuilder =
workPart->Features()->CreateCurvelengthBuilder(nullptr);
curveLengthBuilder->SetSection(section);
curveLengthBuilder->SetDistanceTolerance(0.001); // 设置距离容差
// 设置曲线延伸参数:对称延伸,增量方式
curveLengthBuilder->CurvelengthData()->SetExtensionMethod(
NXOpen::GeometricUtilities::ExtensionMethodIncremental);
curveLengthBuilder->CurvelengthData()->SetExtensionSide(
NXOpen::GeometricUtilities::ExtensionSideSymmetric);
curveLengthBuilder->CurvelengthData()->SetExtensionDirection(
NXOpen::GeometricUtilities::ExtensionDirectionNatural);
// 设置延伸距离(两端各延伸100mm)
curveLengthBuilder->CurvelengthData()->SetStartDistance("100");
curveLengthBuilder->CurvelengthData()->SetEndDistance("100");
// 创建选择规则:基于单条曲线
std::vector<NXOpen::IBaseCurve*> baseCurves(1);
baseCurves[0] = dynamic_cast<NXOpen::IBaseCurve*>(dischargeCurve);
if (!baseCurves[0]) continue; // 类型转换失败则跳过
NXOpen::CurveDumbRule* curveRule =
workPart->ScRuleFactory()->CreateRuleBaseCurveDumb(baseCurves);
// 计算曲线中点作为帮助点(用于选择定位)
double midParam = 0.0;
double midPoint[3] = { 0 };
UF_EVAL_p_t evaluator = NULL;
if (UF_EVAL_initialize(dischargeCurve->Tag(), &evaluator) == 0) {
double limits[2];
if (UF_EVAL_ask_limits(evaluator, limits) == 0) {
midParam = (limits[0] + limits[1]) / 2.0;
UF_EVAL_evaluate(evaluator, 0, midParam, midPoint, NULL);
}
UF_EVAL_free(evaluator);
}
NXOpen::Point3d helpPoint(midPoint[0], midPoint[1], midPoint[2]);
// 创建规则集合
std::vector<NXOpen::SelectionIntentRule*> rules;
rules.push_back(curveRule);
// 添加曲线到截面
section->AddToSection(rules, dischargeCurve, nullptr, nullptr,
helpPoint, NXOpen::Section::ModeCreate, false);
// 提交曲线长度特征
NXOpen::Features::Feature* curveLengthFeature =
dynamic_cast<NXOpen::Features::Feature*>(curveLengthBuilder->Commit());
// 获取新创建的延伸曲线(关键修改:直接添加到外部集合)
if (curveLengthFeature) {
std::vector<NXOpen::NXObject*> createdEntities = curveLengthFeature->GetEntities();
for (NXOpen::NXObject* obj : createdEntities) {
if (NXOpen::Curve* curve = dynamic_cast<NXOpen::Curve*>(obj)) {
extendedCurves.push_back(curve); // 添加到外部集合
}
}
}
// 清理资源
curveLengthBuilder->Destroy();
section->Destroy();
// 显示曲线处理信息
char curveMsg[256];
snprintf(curveMsg, sizeof(curveMsg),
"曲线处理成功:\n原始曲线: %s\n延伸距离: 100 mm\n创建新曲线: %d条",
dischargeCurve->JournalIdentifier().GetText(), extendedCurves.size());
theUI->NXMessageBox()->Show("曲线处理",
NXOpen::NXMessageBox::DialogTypeInformation, curveMsg);
} // 结束出料边曲线遍历循环
// 更新模型
theSession->UpdateManager()->DoUpdate(curveMarkId);
// 显示成功信息
char msg[256];
snprintf(msg, sizeof(msg), "已处理%d条出料边曲线", dischargeCurves.size());
theUI->NXMessageBox()->Show("曲线处理完成",
NXOpen::NXMessageBox::DialogTypeInformation, msg);
// ===== 创建第二个拉伸特征(在曲线长度处理后)=====
try {
// 设置撤销标记
NXOpen::Session::UndoMarkId markId2 = theSession->SetUndoMark(
NXOpen::Session::MarkVisibilityVisible, "出料边拉伸求差");
// 验证延伸曲线是否可用
if (extendedCurves.empty()) {
throw std::runtime_error("没有可用的延伸曲线作为拉伸截面");
}
// 选择第一条延伸曲线作为拉伸截面
NXOpen::Curve* curveForExtrude = extendedCurves[0];
// 创建拉伸构建器
NXOpen::Features::ExtrudeBuilder* extrudeBuilder2 =
workPart->Features()->CreateExtrudeBuilder(nullptr);
// 创建截面对象
NXOpen::Section* section2 = workPart->Sections()->CreateSection(
0.001, 0.001, 0.05); // 距离公差0.001mm,角度公差0.05度
extrudeBuilder2->SetSection(section2);
// 创建曲线选择规则
std::vector<NXOpen::Curve*> sectionCurves2;
sectionCurves2.push_back(curveForExtrude);
NXOpen::SelectionIntentRule* curveRule2 =
workPart->ScRuleFactory()->CreateRuleCurveDumb(sectionCurves2);
// 获取曲线中点作为帮助点
NXOpen::Point3d helpPoint2(0.0, 0.0, 0.0);
{
tag_t curveTag = curveForExtrude->Tag();
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]) std::swap(limits[0], limits[1]);
double midParam = (limits[0] + limits[1]) / 2.0;
double midPoint[3];
if (UF_EVAL_evaluate(evaluator, 0, midParam, midPoint, NULL) == 0) {
helpPoint2 = NXOpen::Point3d(midPoint[0], midPoint[1], midPoint[2]);
}
}
UF_EVAL_free(evaluator);
}
}
// 添加曲线到截面
std::vector<NXOpen::SelectionIntentRule*> rules2;
rules2.push_back(curveRule2);
section2->AddToSection(
rules2, // 曲线规则集合
curveForExtrude, // 主要曲线对象
nullptr, // 不指定曲线起点
nullptr, // 不指定曲线终点
helpPoint2, // 帮助点(中点)
NXOpen::Section::ModeCreate // 创建模式
);
// 设置拉伸方向(与第一个拉伸相同)
NXOpen::Point3d origin(0.0, 0.0, 0.0);
NXOpen::Direction* extrudeDirection2 =
workPart->Directions()->CreateDirection(
origin,
directionVector, // 使用相同的方向矢量
NXOpen::SmartObject::UpdateOptionWithinModeling
);
extrudeBuilder2->SetDirection(extrudeDirection2);
// 设置拉伸范围
NXOpen::GeometricUtilities::Limits* limitsObj2 = extrudeBuilder2->Limits();
// 起始距离 = 材料厚度(与第一个拉伸相同)
limitsObj2->StartExtend()->Value()->SetRightHandSide(
std::to_string(materialThickness).c_str());
// 结束距离 = 扫描高度 + 10mm
limitsObj2->EndExtend()->Value()->SetRightHandSide(
std::to_string(scanHeight + 10.0).c_str());
// ===== 设置偏置模式 =====
// 获取拉伸特征的偏置构建器
NXOpen::GeometricUtilities::FeatureOffset* featureOffset = extrudeBuilder2->Offset();
// 设置非对称偏置(两侧不同距离)
featureOffset->SetOption(NXOpen::GeometricUtilities::TypeNonsymmetricOffset);
// 设置具体偏置值
featureOffset->StartOffset()->SetRightHandSide("0"); // 起始端偏置0
featureOffset->EndOffset()->SetRightHandSide("100");
// 设置拔模类型:从起始位置简单拔模
extrudeBuilder2->Draft()->SetDraftOption(
NXOpen::GeometricUtilities::SimpleDraft::SimpleDraftTypeSimpleFromStart);
// 设置前拔模角度(从截面开始处拔模)
extrudeBuilder2->Draft()->FrontDraftAngle()->SetRightHandSide(
std::to_string(currentAngle).c_str());
// 设置后拔模角度(这里我们设为0,因为只需要单边拔模)
extrudeBuilder2->Draft()->BackDraftAngle()->SetRightHandSide("0");
// ===== 设置布尔操作 =====
// 设置操作类型:求差(从第一个拉伸实体中减去此拉伸)
extrudeBuilder2->BooleanOperation()->SetType(
NXOpen::GeometricUtilities::BooleanOperation::BooleanTypeSubtract);
// 设置布尔操作类型(创建新实体)
extrudeBuilder2->BooleanOperation()->SetType(
NXOpen::GeometricUtilities::BooleanOperation::BooleanTypeCreate);
//// 设置布尔操作类型(求差)
//// 设置目标体(第一个拉伸创建的实体)
// std::vector<NXOpen::Body*> targetBodies;
// if (firstExtrudeBody) {
// targetBodies.push_back(firstExtrudeBody);
// extrudeBuilder2->BooleanOperation()->SetTargetBodies(targetBodies);
// }
// else {
// throw std::runtime_error("第一个拉伸实体未找到");
// }//求差
// ===== 执行拉伸操作 =====
NXOpen::NXObject* featureNXObject2 = extrudeBuilder2->Commit();
// 检查是否成功创建特征
if (!featureNXObject2) {
throw std::runtime_error("第二个拉伸特征创建失败");
}
// ===== 新增:找出拉伸截面中点并与边界曲线比较 =====
// 在函数作用域顶部声明
NXOpen::Curve* targetBoundaryCurve = nullptr;
try {
// 1. 确保有两条延伸曲线和两条边界曲线
if (extendedCurves.size() < 2 || boundaryCurves.size() < 2) {
throw std::runtime_error("需要两条延伸曲线和两条边界曲线");
}
// 2. 获取两条延伸曲线和两条边界曲线
NXOpen::Curve* extCurve1 = extendedCurves[0];
NXOpen::Curve* extCurve2 = extendedCurves[1];
NXOpen::Curve* bndCurve1 = boundaryCurves[0];
NXOpen::Curve* bndCurve2 = boundaryCurves[1];
// 3. 计算所有曲线的中点
struct CurveMidPoint {
NXOpen::Curve* curve;
double midPoint[3];
};
// 计算中点函数
auto calculateMidPoint = [](NXOpen::Curve* curve) -> double* {
static double midPoint[3] = { 0 };
UF_EVAL_p_t evaluator = NULL;
if (UF_EVAL_initialize(curve->Tag(), &evaluator) == 0) {
double limits[2];
if (UF_EVAL_ask_limits(evaluator, limits) == 0) {
double midParam = (limits[0] + limits[1]) / 2.0;
UF_EVAL_evaluate(evaluator, 0, midParam, midPoint, NULL);
}
UF_EVAL_free(evaluator);
}
return midPoint;
};
// 存储所有曲线的中点
CurveMidPoint extMid1 = { extCurve1, {0} };
memcpy(extMid1.midPoint, calculateMidPoint(extCurve1), 3 * sizeof(double));
CurveMidPoint extMid2 = { extCurve2, {0} };
memcpy(extMid2.midPoint, calculateMidPoint(extCurve2), 3 * sizeof(double));
CurveMidPoint bndMid1 = { bndCurve1, {0} };
memcpy(bndMid1.midPoint, calculateMidPoint(bndCurve1), 3 * sizeof(double));
CurveMidPoint bndMid2 = { bndCurve2, {0} };
memcpy(bndMid2.midPoint, calculateMidPoint(bndCurve2), 3 * sizeof(double));
// 4. 计算距离函数
auto distance = [](double p1[3], double p2[3]) -> double {
double dx = p1[0] - p2[0];
double dy = p1[1] - p2[1];
double dz = p1[2] - p2[2];
return sqrt(dx * dx + dy * dy + dz * dz);
};
// 5. 计算所有可能的距离组合
double d11 = distance(extMid1.midPoint, bndMid1.midPoint); // 延伸1-边界1
double d12 = distance(extMid1.midPoint, bndMid2.midPoint); // 延伸1-边界2
double d21 = distance(extMid2.midPoint, bndMid1.midPoint); // 延伸2-边界1
double d22 = distance(extMid2.midPoint, bndMid2.midPoint); // 延伸2-边界2
// 6. 找出所有可能的配对组合
struct Pairing {
NXOpen::Curve* extCurve;
NXOpen::Curve* bndCurve;
double distance;
};
std::vector<Pairing> allPairs = {
{extCurve1, bndCurve1, d11},
{extCurve1, bndCurve2, d12},
{extCurve2, bndCurve1, d21},
{extCurve2, bndCurve2, d22}
};
// 7. 找出最短距离的组合
auto minPair = *std::min_element(allPairs.begin(), allPairs.end(),
[](const Pairing& a, const Pairing& b) {
return a.distance < b.distance;
});
// 8. 从原始集合中移除已配对的曲线
std::vector<NXOpen::Curve*> remainingExtCurves = { extCurve1, extCurve2 };
std::vector<NXOpen::Curve*> remainingBndCurves = { bndCurve1, bndCurve2 };
auto removeCurve = [](std::vector<NXOpen::Curve*>& vec, NXOpen::Curve* curve) {
vec.erase(std::remove(vec.begin(), vec.end(), curve), vec.end());
};
removeCurve(remainingExtCurves, minPair.extCurve);
removeCurve(remainingBndCurves, minPair.bndCurve);
// 9. 创建最终配对结果
std::vector<std::pair<NXOpen::Curve*, NXOpen::Curve*>> closestPairs;
// 第一对:最短距离组合
closestPairs.push_back({ minPair.extCurve, minPair.bndCurve });
// 第二对:剩余曲线组合
if (!remainingExtCurves.empty() && !remainingBndCurves.empty()) {
closestPairs.push_back({ remainingExtCurves[0], remainingBndCurves[0] });
}
// 10. 验证配对结果
if (closestPairs.size() != 2) {
throw std::runtime_error("无法创建完整的配对组合");
}
// ===== 新增:高亮显示与extendedCurves[0]配对的边界线 =====
NXOpen::Curve* targetExtCurve = extendedCurves[0];
NXOpen::Curve* targetBoundaryCurve = nullptr;
// 在配对结果中查找与extendedCurves[0]配对的边界曲线
for (const auto& pair : closestPairs) {
if (pair.first == targetExtCurve) {
targetBoundaryCurve = pair.second;
break;
}
}
// 高亮相关边界曲线
UF_DISP_set_highlight(targetBoundaryCurve->Tag(), 1); // 高亮显示
// 刷新显示
UF_DISP_refresh();
// 显示配对结果
char pairInfo[512];
snprintf(pairInfo, sizeof(pairInfo),
"配对结果:\n"
"1. %s - %s (距离: %.4f mm)\n"
"2. %s - %s",
closestPairs[0].first->JournalIdentifier().GetText(),
closestPairs[0].second->JournalIdentifier().GetText(),
minPair.distance,
closestPairs[1].first->JournalIdentifier().GetText(),
closestPairs[1].second->JournalIdentifier().GetText());
theUI->NXMessageBox()->Show("曲线配对结果",
NXOpen::NXMessageBox::DialogTypeInformation, pairInfo);
}
catch (std::exception& ex) {
char warnMsg[256];
snprintf(warnMsg, sizeof(warnMsg), "曲线中点配对失败: %s", ex.what());
theUI->NXMessageBox()->Show("警告",
NXOpen::NXMessageBox::DialogTypeWarning, warnMsg);
}
// 获取创建的实体
NXOpen::Features::Extrude* extrudeFeature2 =
dynamic_cast<NXOpen::Features::Extrude*>(featureNXObject2);
std::vector<NXOpen::Body*> resultBodies2;
if (extrudeFeature2) {
resultBodies2 = extrudeFeature2->GetBodies();
}
// ===== 新增:判断边界曲线能否投影到第二个拉伸实体上 =====
bool canProject = false; // 投影能力标志
if (targetBoundaryCurve && !resultBodies2.empty()) {
try {
// 1. 获取第二个拉伸实体的所有面
std::vector<tag_t> bodyFaces;
tag_t bodyTag = resultBodies2[0]->Tag();
int faceCount = 0;
uf_list_p_t faceList = NULL;
if (UF_MODL_ask_body_faces(bodyTag, &faceList) == 0) {
UF_MODL_ask_list_count(faceList, &faceCount);
bodyFaces.reserve(faceCount);
for (int i = 0; i < faceCount; i++) {
tag_t faceTag = NULL_TAG;
UF_MODL_ask_list_item(faceList, i, &faceTag);
bodyFaces.push_back(faceTag);
}
UF_MODL_delete_list(&faceList);
}
// 2. 设置投影方向
double projDirection[3] = {
directionVector.X,
directionVector.Y,
directionVector.Z
};
// 3. 准备投影曲线数据
tag_t curveTag = targetBoundaryCurve->Tag();
// 创建曲线列表
uf_list_p_t curveList = NULL;
UF_MODL_create_list(&curveList);
UF_MODL_put_list_item(curveList, curveTag); // 正确添加曲线到列表
// 创建面列表
uf_list_p_t faceRefs = NULL;
UF_MODL_create_list(&faceRefs);
for (tag_t faceTag : bodyFaces) {
UF_MODL_put_list_item(faceRefs, faceTag);
}
// 4. 创建投影曲线
tag_t projCurveFeatTag = NULL_TAG;
int along_face = 0; // 0 = 使用投影向量,1 = 使用面法线
int status = UF_MODL_create_proj_curves(
curveList, // 输入曲线列表
faceRefs, // 目标面列表
along_face, // 投影方向指定方式
projDirection, // 投影方向矢量
&projCurveFeatTag // 输出投影特征标记
);
// 5. 检查投影结果
if (status == 0 && projCurveFeatTag != NULL_TAG) {
canProject = true;
// 获取创建的投影曲线
uf_list_p_t resultCurves = NULL;
UF_MODL_ask_proj_curves(projCurveFeatTag, &resultCurves);
if (resultCurves) {
int resultCount = 0;
UF_MODL_ask_list_count(resultCurves, &resultCount);
// 删除生成的投影曲线(不需要保留)
for (int i = 0; i < resultCount; i++) {
tag_t resultTag = NULL_TAG;
UF_MODL_ask_list_item(resultCurves, i, &resultTag);
UF_OBJ_delete_object(resultTag);
}
UF_MODL_delete_list(&resultCurves);
}
// 删除投影特征
UF_OBJ_delete_object(projCurveFeatTag);
}
// 6. 释放列表资源
if (curveList) UF_MODL_delete_list(&curveList);
if (faceRefs) UF_MODL_delete_list(&faceRefs);
// 7. 显示投影测试结果
char projMsg[256];
snprintf(projMsg, sizeof(projMsg),
"投影测试结果: %s\n"
"目标曲线: %s\n"
"实体面数: %d\n"
"投影状态: %d",
canProject ? "成功" : "失败",
targetBoundaryCurve->JournalIdentifier().GetText(),
faceCount,
status);
theUI->NXMessageBox()->Show("投影验证",
NXOpen::NXMessageBox::DialogTypeInformation, projMsg);
}
catch (...) {
theUI->NXMessageBox()->Show("投影错误",
NXOpen::NXMessageBox::DialogTypeError,
"投影验证过程中发生未知异常");
}
}
// 清理资源
extrudeBuilder2->Destroy();
section2->Destroy();
// 显示成功信息
char successMsg[256];
snprintf(successMsg, sizeof(successMsg),
"第二个拉伸创建成功!\n"
"拔模角度: %.2f°\n"
"偏置范围: 0-100 mm\n"
"创建实体: %d个",
currentAngle, resultBodies2.size());
theUI->NXMessageBox()->Show("操作结果",
NXOpen::NXMessageBox::DialogTypeInformation, successMsg);
}
catch (std::exception& ex) {
// 错误处理
char errMsg[256];
snprintf(errMsg, sizeof(errMsg), "第二个拉伸创建失败: %s", ex.what());
theUI->NXMessageBox()->Show("错误",
NXOpen::NXMessageBox::DialogTypeError, errMsg);
errorCode = 7; // 设置新的错误代码
}
// 刷新显示
UF_DISP_refresh();
} // 结束出料边曲线处理try块
catch (std::exception& ex) {
char errMsg[256];
snprintf(errMsg, sizeof(errMsg), "曲线处理失败: %s", ex.what());
theUI->NXMessageBox()->Show("错误",
NXOpen::NXMessageBox::DialogTypeError, errMsg);
errorCode = 6; // 设置新的错误代码
}
// 刷新显示
UF_DISP_refresh();
} // 结束主try块
catch (std::exception& ex)
{
// 异常处理
char errMsg[256];
snprintf(errMsg, sizeof(errMsg), "操作失败: %s", ex.what());
qiaowei_tool::theUI->NXMessageBox()->Show("错误",
NXOpen::NXMessageBox::DialogTypeError, errMsg);
errorCode = 1;
}
return errorCode;
}在验证投影结果时nx没有弹出投影的结果消息窗口,其他的操作有正常提示,以下是nx日志:&MACRO MENU, 0, UG_LWIN_FILE_EXIT ListingWindowMenuBar !
&MACRO FOCUS CHANGE IN 1
&MACRO WINDOW RESIZE 1.000000 16.635417 8.666667 -1.000000 -0.520977 1.000000 0.520977
&MACRO FOCUS CHANGE IN 1
&MACRO WINDOW RESIZE 1.000000 16.635417 8.666667 -1.000000 -0.520977 1.000000 0.520977
&MACRO CURSOR_EVENT 1001 3,1,100,0 ! single_pt, mb1/0+0, , nn
&MACRO CPOS -148.435137952775,8.98652069348885,17.2567514929381
&MACRO MENU, 0, UG_FILE_RUN_UFUN UG_GATEWAY_MAIN_MENUBAR <Ctrl U> ## !
&MACRO FILE_DIALOG_BEGIN 0, ! filebox with tools_data
&MACRO FILE_DIALOG_UPDATE 115
&MACRO FOCUS CHANGE IN 1
&MACRO WINDOW RESIZE 1.000000 16.635417 8.666667 -1.000000 -0.520977 1.000000 0.520977
&MACRO FOCUS CHANGE IN 1
&MACRO WINDOW RESIZE 1.000000 16.635417 8.666667 -1.000000 -0.520977 1.000000 0.520977
&MACRO FILE_DIALOG_END
&MACRO FILE_BOX -2,@@@D:\NXopen\BaiduSyncdisk\studio\qiaowei_tool\x64\Debug\qiaowei_tool.dll@@@D:\NXopen\BaiduSyncdisk\studio\qiaowei_tool\x64\Debug\*.DLL@@@ 0 ! Execute User Function
Native license authentication detected presence of User Function license
Successfully loaded dynamic module D:\NXopen\BaiduSyncdisk\studio\qiaowei_tool\x64\Debug\qiaowei_tool.dll
Loaded module d:\nxopen\baidusyncdisk\studio\qiaowei_tool\x64\debug\qiaowei_tool.dll 7ffcbb380000 37000 2094fc5b-4c4a93bb-437b0880-3aa1c29-27 version = 0
Loaded module c:\program files\common files\microsoft shared\ink\tiptsf.dll 7ffcdff50000 a3000 3d8a2dd4-31bd6c07-d7f7bc8a-d7d0a799-1 version = 10.0.22621.5415
Loaded module c:\windows\system32\windows.ui.dll 7ffce5ba0000 17e000 d0856ad-5495f988-89bf82d2-ecc67a77-1 version = 10.0.22621.5415
Loaded module c:\windows\system32\bcp47langs.dll 7ffcf3f40000 60000 8a984a73-133d2a3b-e559a66a-60614a82-1 version = 10.0.22621.5262
Loaded module c:\windows\system32\globinputhost.dll 7ffcb96c0000 29000 acd3a3c3-3acf7afc-e1a9d9d0-4b27980c-1 version = 10.0.22621.5415
Loaded module c:\windows\system32\windows.globalization.dll 7ffce3bb0000 1c4000 559b58b7-2e3ae37f-e6520b28-9f20486f-1 version = 10.0.22621.5415
Loaded module c:\windows\system32\msftedit.dll 7ffcb79c0000 382000 1c36c7d-89f1c85b-bc93204e-b8470fea-1 version = 10.0.22621.5547
Block Styler: Could not find the file at qiaowei_tool.dlx. The file will be searched in user directories
Block Styler: Found the file at D:\Program Files\Siemens\NX2212\MICHTOOLS\application\qiaowei_tool.dlx
UNDO_UG: Recyclable status of mark 366 set to False
Block Styler: Could not find the file UICOMP_edge_select. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_edge_select. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_toggle. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_toggle. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_vector. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_edge_select. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_edge_select. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_toggle. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_toggle. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_expression. The file will be searched in user directories
Block Styler: Could not find the file UICOMP_vector. The file will be searched in user directories
&MACRO ASK_ITEM 851968 (1 BOOL 0) = 1 ! 显示之前状态
&MACRO ASK_ITEM 851968 (1 BOOL 0) = 0 ! 显示之前状态
&MACRO ASK_ITEM 1638400 (1 BOOL 0) = 1 ! 显示之前状态
&MACRO ASK_ITEM 1638400 (1 BOOL 0) = 0 ! 显示之前状态
&MACRO ASK_ITEM 5046272 (1 BOOL 0) = 1 ! 倒R角
&MACRO ASK_ITEM 5046272 (1 BOOL 0) = 0 ! 倒R角
&MACRO ASK_ITEM 5898240 (1 BOOL 0) = 1 ! 两端偏置
&MACRO ASK_ITEM 5898240 (1 BOOL 0) = 0 ! 两端偏置
&MACRO ASK_ITEM 6815744 (1 OPTT 0) = 10 0 ! -ZC-axis
&MACRO ASK_ITEM 6815744 (1 OPTT 0) = 10 1 ! -ZC-axis
&MACRO ASK_ITEM 6815744 (1 OPTT 0) = 10 1 ! -ZC-axis
&MACRO ASK_ITEM 6815744 (1 OPTT 0) = 10 0 ! -ZC-axis
&MACRO ASK_ITEM 6815744 (1 OPTT 0) = 10 0 ! -ZC-axis
&MACRO ASK_ITEM 6815744 (1 OPTT 0) = 10 0 ! -ZC-axis
&MACRO EVENT FOCUS_IN 0 0, 2359298, 0, 0, 0! 出料沉桥
&MACRO ASK_ITEM 2359298 (1 STRN 0) = "0" ! 出料沉桥
&MACRO DIALOG_BEGIN "桥位tool-MiCH-明" 0 ! DA2
&MACRO BEG_ITEM 327680 (1 BOOL 0) = 0 ! Curve
&MACRO BEG_ITEM 851968 (1 BOOL 0) = 0 ! 显示之前状态
&MACRO BEG_ITEM 1114112 (1 BOOL 0) = 0 ! Curve
&MACRO BEG_ITEM 1638400 (1 BOOL 0) = 0 ! 显示之前状态
&MACRO BEG_ITEM 2359298 (1 STRN 0) = "0" ! 出料沉桥
&MACRO BEG_ITEM 3014658 (1 STRN 0) = "65" ! 上模厚度
&MACRO BEG_ITEM 3670018 (1 STRN 0) = "0" ! 进料沉桥
&MACRO BEG_ITEM 4325378 (1 OPTM 0) = 1 ! °
&MACRO BEG_ITEM 4325379 (1 STRN 0) = "20" ! 倒桥角度
&MACRO BEG_ITEM 5046272 (1 BOOL 0) = 0 ! 倒R角
&MACRO BEG_ITEM 5505026 (1 STRN 0) = "50" ! 倒角R
&MACRO BEG_ITEM 5898240 (1 BOOL 0) = 0 ! 两端偏置
&MACRO BEG_ITEM 6356994 (1 STRN 0) = "20" ! 偏置距离
&MACRO BEG_ITEM 6815744 (1 OPTT 0) = 10 0 ! -ZC-axis
&MACRO BEG_ITEM 7798784 (1 OPTM 0) = 10 ! -ZC-axis
&MACRO BEG_ITEM 7798786 (1 TOOL 0) = 5 ! -ZC-axis
&MACRO BEG_ITEM 9043970 (1 BOOL 0) = 1 ! Preview
&MACRO ASK_ITEM 327680 (1 BOOL 0) = 0 ! Curve
&MACRO ASK_ITEM 327680 (1 BOOL 0) = 1 ! Curve
&MACRO EVENT FOCUS_OUT 0 0, 2359298, 0, 0, 0! 出料沉桥
&MACRO ASK_ITEM 2359298 (1 STRN 0) = "0" ! 出料沉桥
&MACRO FOCUS CHANGE IN 1
&MACRO WINDOW RESIZE 1.000000 16.635417 8.666667 -1.000000 -0.520977 1.000000 0.520977
&MACRO CURSOR_EVENT 1001 3,1,100,0 ! single_pt, mb1/0+0, , nn
&MACRO CPOS -55.8727588203158,0.494559305189874,17.2567514929381
!!!&MACRO EVENT FOCUS_IN 0 0, 2359298, 0, 0, 0! (Application CB Nested)
!!!&MACRO ASK_ITEM 2359298 (1 STRN 0) = "0" ! 出料沉桥
&MACRO EVENT FOCUS_OUT 0 0, 2359298, 0, 0, 0! 出料沉桥
&MACRO ASK_ITEM 2359298 (1 STRN 0) = "0" ! 出料沉桥
&MACRO FOCUS CHANGE IN 1
&MACRO WINDOW RESIZE 1.000000 16.635417 8.666667 -1.000000 -0.520977 1.000000 0.520977
&MACRO CURSOR_EVENT 1001 3,1,100,0 ! single_pt, mb1/0+0, , nn
&MACRO CPOS -25.5847632020494,-6.29900980544931,17.2567514929381
!!!&MACRO EVENT FOCUS_IN 0 0, 2359298, 0, 0, 0! (Application CB Nested)
!!!&MACRO ASK_ITEM 2359298 (1 STRN 0) = "0" ! 出料沉桥
&MACRO CURSOR_EVENT 1001 106,0,201,0 ! motion_pb, mb0/0+0, , nn
&MACRO CPOS -42.2856205990374,-12.8095135364785,17.2567514929381
&MACRO EVENT FOCUS_OUT 0 0, 2359298, 0, 0, 0! 出料沉桥
&MACRO ASK_ITEM 2359298 (1 STRN 0) = "0" ! 出料沉桥
&MACRO EVENT FOCUS_IN 0 0, 1114112, 0, 0, 0! Curve
&MACRO ASK_ITEM 1114112 (1 BOOL 0) = 0 ! Curve
&MACRO EVENT VALUE_CHANGED 0 0, 1114112, 0, 0, 0! Curve
&MACRO ASK_ITEM 1114112 (1 BOOL 0) = 1 ! Curve
&MACRO ASK_ITEM 327680 (1 BOOL 0) = 1 ! Curve
&MACRO ASK_ITEM 327680 (1 BOOL 0) = 0 ! Curve
&MACRO ASK_ITEM 1114112 (1 BOOL 0) = 1 ! Curve
&MACRO FOCUS CHANGE IN 1
&MACRO WINDOW RESIZE 1.000000 16.635417 8.666667 -1.000000 -0.520977 1.000000 0.520977
&MACRO CURSOR_EVENT 1001 3,1,100,0 ! single_pt, mb1/0+0, , nn
&MACRO CPOS -50.4945166077264,-2.9022252501297,17.2567514929381
&MACRO CURSOR_EVENT 1001 3,1,100,0 ! single_pt, mb1/0+0, , nn
&MACRO CPOS -48.5130589504566,-0.0715714540300532,17.2567514929381
!!!&MACRO EVENT FOCUS_IN 0 0, 1114112, 0, 0, 0! (Application CB Nested)
!!!&MACRO ASK_ITEM 1114112 (1 BOOL 0) = 1 ! Curve
&MACRO FOCUS CHANGE IN 1
&MACRO WINDOW RESIZE 1.000000 16.635417 8.666667 -1.000000 -0.520977 1.000000 0.520977
&MACRO CURSOR_EVENT 1001 3,1,100,0 ! single_pt, mb1/0+0, , nn
&MACRO CPOS -36.9073783864481,-6.01594442583933,17.2567514929381
!!!&MACRO EVENT FOCUS_IN 0 0, 1114112, 0, 0, 0! (Application CB Nested)
!!!&MACRO ASK_ITEM 1114112 (1 BOOL 0) = 1 ! Curve
&MACRO CURSOR_EVENT 1001 106,0,201,0 ! motion_pb, mb0/0+0, , nn
&MACRO CPOS -61.2510010329051,-19.3200172675077,17.2567514929381
&MACRO OK 0 0 ! OK Callback
&MACRO ASK_ITEM 1114112 (1 BOOL 0) = 1 ! Curve
&MACRO ASK_ITEM 1114112 (1 BOOL 0) = 0 ! Curve
&MACRO MESSAGE_BOX -2 已创建两条连接直线:
&MACRO MESSAGE_TEXT 1. 最短距离直线: 30.51 mm
&MACRO MESSAGE_TEXT 2. 剩余端点直线: 31.69 mm
&MACRO MESSAGE_BOX -2 创建新实体成功!
&MACRO MESSAGE_TEXT 实体数量: 1
&MACRO MESSAGE_TEXT 起始距离: 0.00 mm
&MACRO MESSAGE_TEXT 结束距离: 65.00 mm
&MACRO MESSAGE_BOX -2 曲线处理成功:
&MACRO MESSAGE_TEXT 原始曲线: ENTITY 3 5 1
&MACRO MESSAGE_TEXT 延伸距离: 100 mm
&MACRO MESSAGE_TEXT 创建新曲线: 1条
&MACRO MESSAGE_BOX -2 曲线处理成功:
&MACRO MESSAGE_TEXT 原始曲线: ENTITY 3 5 1
&MACRO MESSAGE_TEXT 延伸距离: 100 mm
&MACRO MESSAGE_TEXT 创建新曲线: 2条
&MACRO MESSAGE_BOX -2, 已处理2条出料边曲线
&MACRO MESSAGE_BOX -2 配对结果:
&MACRO MESSAGE_TEXT 1. ENTITY 3 2 1 - ENTITY 3 8 1 (距离: 9.4373 mm)
&MACRO MESSAGE_TEXT 2. ENTITY 3 1 1 - ENTITY 3 7 1
&MACRO MESSAGE_BOX -2 第二个拉伸创建成功!
&MACRO MESSAGE_TEXT 拔模角度: 20.00°
&MACRO MESSAGE_TEXT 偏置范围: 0-100 mm
&MACRO MESSAGE_TEXT 创建实体: 1个
!!!&MACRO ASK_ITEM 2359298 (1 STRN 0) = "0" ! 出料沉桥
!!!&MACRO ASK_ITEM 2359298 (1 STRN 0) = "0" ! 出料沉桥
!!!&MACRO ASK_ITEM 3014658 (1 STRN 0) = "65" ! 上模厚度
!!!&MACRO ASK_ITEM 3014658 (1 STRN 0) = "65" ! 上模厚度
!!!&MACRO ASK_ITEM 3670018 (1 STRN 0) = "0" ! 进料沉桥
!!!&MACRO ASK_ITEM 3670018 (1 STRN 0) = "0" ! 进料沉桥
!!!&MACRO ASK_ITEM 4325379 (1 STRN 0) = "20" ! 倒桥角度
!!!&MACRO ASK_ITEM 4325379 (1 STRN 0) = "20" ! 倒桥角度
!!!&MACRO ASK_ITEM 5505026 (1 STRN 0) = "50" ! 倒角R
!!!&MACRO ASK_ITEM 5505026 (1 STRN 0) = "50" ! 倒角R
!!!&MACRO ASK_ITEM 6356994 (1 STRN 0) = "20" ! 偏置距离
!!!&MACRO ASK_ITEM 6356994 (1 STRN 0) = "20" ! 偏置距离
&MACRO END_ITEM 327680 (1 BOOL 0) = 0 ! Curve
&MACRO END_ITEM 851968 (1 BOOL 0) = 0 ! 显示之前状态
&MACRO END_ITEM 1114112 (1 BOOL 0) = 0 ! Curve
&MACRO END_ITEM 1638400 (1 BOOL 0) = 0 ! 显示之前状态
&MACRO END_ITEM 2359298 (1 STRN 0) = "0" ! 出料沉桥
&MACRO END_ITEM 3014658 (1 STRN 0) = "65" ! 上模厚度
&MACRO END_ITEM 3670018 (1 STRN 0) = "0" ! 进料沉桥
&MACRO END_ITEM 4325378 (1 OPTM 0) = 1 ! °
&MACRO END_ITEM 4325379 (1 STRN 0) = "20" ! 倒桥角度
&MACRO END_ITEM 5046272 (1 BOOL 0) = 0 ! 倒R角
&MACRO END_ITEM 5505026 (1 STRN 0) = "50" ! 倒角R
&MACRO END_ITEM 5898240 (1 BOOL 0) = 0 ! 两端偏置
&MACRO END_ITEM 6356994 (1 STRN 0) = "20" ! 偏置距离
&MACRO END_ITEM 6815744 (1 OPTT 0) = 10 0 ! -ZC-axis
&MACRO END_ITEM 7798784 (1 OPTM 0) = 10 ! -ZC-axis
&MACRO END_ITEM 7798786 (1 TOOL 0) = 5 ! -ZC-axis
&MACRO END_ITEM 9043970 (1 BOOL 0) = 1 ! Preview
&MACRO DIALOG_END -2, 0 ! 桥位tool-MiCH-明: OK
UNDO_UG: Recyclable status of mark 366 set to True
Unloading D:\NXopen\BaiduSyncdisk\studio\qiaowei_tool\x64\Debug\qiaowei_tool.dll
&MACRO MENU, 0, UG_HELP_SYSTEM_LOG UG_GATEWAY_MAIN_MENUBAR <RibbonTopBar->MenuBar->UG_HELP> ## !
最新发布