//用户代码
#include <uf_defs.h>
#include <NXOpen/NXException.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/BasePart.hxx>
#include <NXOpen/Expression.hxx>
#include <NXOpen/ExpressionCollection.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Preferences_SessionModeling.hxx>
#include <NXOpen/Preferences_SessionPreferences.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/Unit.hxx>
#include <NXOpen/UnitCollection.hxx>
#include <NXOpen/Update.hxx>
#include <NXOpen/ExpressionGroup.hxx>
#include <NXOpen/ExpressionGroupCollection.hxx>

void MyClass::do_it()
{

// TODO: add your code here

//用户代码

//遍历工作部件表达式
ExpressionCollection* Expressions = workPart->Expressions();
ExpressionCollection::iterator Exp_All;
char Char_Exp_Val_double[256];
for (Exp_All = Expressions->begin(); Exp_All != Expressions->end(); ++Exp_All)
{
Expression* Exp1 = dynamic_cast<Expression*> (* Exp_All);
NXString Exp_Name1 = Exp1->Name();//获取表达式名字
NXString Exp_Type = Exp1->Type();//获取表达式类型
theSession->ListingWindow()->Open();
//theSession->ListingWindow()->WriteLine(Exp_Name1 + "表达式类型:" + Exp_Type );

//std::vector<string> Exp_Sring1;
if (strcmp(Exp_Type.GetLocaleText(), "String") == 0)
{
theSession->ListingWindow()->WriteLine("字符串表达式:" + Exp_Name1 + " = " );
}
else if (strcmp(Exp_Type.GetLocaleText(), "Number") == 0)
{
double Exp_Val_double = Exp1->Value();
sprintf(Char_Exp_Val_double, "%.2f", Exp_Val_double);
theSession->ListingWindow()->WriteLine("数量表达式:" + Exp_Name1 + " = " + Char_Exp_Val_double);
}

}

}

NXOpen遍历工作部件表达式的更多相关文章

  1. NX二次开发-遍历当前part所有component,把装配子部件设置成工作部件

    NX11+VS2013 #include <uf.h> #include <uf_disp.h> #include <uf_modl.h> #include < ...

  2. POI教程之第二讲:创建一个时间格式的单元格,处理不同内容格式的单元格,遍历工作簿的行和列并获取单元格内容,文本提取

    第二讲 1.创建一个时间格式的单元格 Workbook wb=new HSSFWorkbook(); // 定义一个新的工作簿 Sheet sheet=wb.createSheet("第一个 ...

  3. NX二次开发-UFUN输入Part的TAG,获取整个部件表达式的TAG和表达式个数UF_MODL_ask_exps_of_part

    NX9+VS2012 #include <uf.h> #include <uf_modl.h> #include <uf_part.h> UF_initialize ...

  4. 【NX二次开发】按层查找工作部件中的对象 UF_LAYER_cycle_by_layer

    第一次调用 :返回第一个启用层中的第一个对象. 第二次调用 :返回下一个已启用层中的下一个对象. 最后一次调用:当所有对象都被耗尽时,将返回object_tag = NULL_TAG. 在循环数据库时 ...

  5. QHBoxLayout 、QFormLayout 遍历子部件,查找QLineEdit控件

    布局如下: QLineEdit * edit1 = new QLineEdit; QLineEdit * edit2 = new QLineEdit; QLineEdit * edit3 = new ...

  6. C# 表达式树遍历(二)

    一.前言 上一篇我们对表达式树有了初步的认识,这里我们将对表达式树进行遍历,只有弄清楚了他的运行原理,我们才可以对他进行定制化修改. 表达式系列目录 C# 表达式树讲解(一) C# 表达式树遍历(二) ...

  7. 【NX二次开发】UF_CSYS_map_point()函数,绝对坐标,工作坐标,部件之间坐标转换。

    UF_CSYS_map_point用来变换点的坐标,比较简单且实用.例如工作坐标系与绝对坐标系转换,一个部件的坐标与另一个部件坐标系之间的转换.下面的例子是在三个坐标下创建三个点相对坐标为{10,50 ...

  8. C#实现创建、编辑NX表达式

    在NX8.5中使用C#编辑表达式中有个坑,part.Expressions.Edit该方法鲁棒性很差,当表达式有错时也能编辑成功(手动在NX中增加错误表达式会有弹框,无法创建,而该方法却可以,疑是bu ...

  9. ASP.NET Core中使用表达式树创建URL

    当我们在ASP.NET Core中生成一个action的url会这样写: var url=_urlHelper.Action("Index", "Home"); ...

  10. NX二次开发-NXOpen::WCS Class Reference

    NX11+VS2013 #include <NXOpen/Part.hxx> #include <NXOpen/PartCollection.hxx> #include < ...

随机推荐

  1. kubernetes强制删除namespace

    1.执行命令删除namespace后一直显示Terminating,无法删除namespace [root@k8s-master1 ~]# kubectl get ns NAME STATUS AGE ...

  2. ORihard KCU116E: 经济实惠的 100Gbps 网络和存储 FPGA 开发平台

    ORihard KCU116E: 经济实惠的 100Gbps 网络和存储 FPGA 开发平台   ORihard KCU116E: 经济实惠的 100Gbps 网络和存储 FPGA 开发平台 Kint ...

  3. django:django同步数据库的时候app models表没有成功创建

    解决方式: python3 manage.py makemigrations --empty managerbook  # managerbook就是你的app名字,此处要写成自己的app名字 pyt ...

  4. 解决xpath提取的数据列表,保存时不能一一对应的问题

    """拉链函数,zip将几个列表的数据进行封装,一一对应.如果一方列表的数据,比另一方少,那么按数据少的一方对应"""# 数据个数对应相等l ...

  5. mqtt的使用

    1.mqttws31.js /******************************************************************************* * Cop ...

  6. Cxf框架中@WebService注解的使用

    最近工作中总是不可避免的使用WebService来对接功能,经过自己一番摸索,总结出了一些使用方法,做一下记录: 记录了两个SpringBoot版本使用WebService的一些问题和用法,Sprin ...

  7. C语言博客作业07

    1.作业头 这个作业属于哪个课程 https://edu.cnblogs.com/campus/zswxy/SE2020-3 这个作业要求在哪里 https://edu.cnblogs.com/cam ...

  8. python + selenium 常用公共方法封装

    selenium 环境配置及浏览器驱动的安装:https://www.cnblogs.com/gancuimian/p/16435300.html uiautomator2 常用公共方法封装见之前的帖 ...

  9. js 获取年月日时分秒,星期

    getDate() { var date = new Date() // 获取时间 var year = date.getFullYear() // 获取年 var month = date.getM ...

  10. jmeter转义

    /reportDetail?md5Key%3De7beff4c73ccd8f1cb01c383eda7fed0%26cid%3D1344500703825739777%26isShow%3Dfalse ...