NX二次开发-使用NXOPEN C#手工搭建开发环境配置

新建类库

进来后编译代码,成功

 添加NXOPEN的库到项目中

 

 

 不同NX版本,可能dll所在位置不一样,NX11以上版本在NXBIN这里,NX11以下版本大概在UGII。

 添加头文件

using NXOpen;
using NXOpen.Utilities;
using NXOpen.UF;

添加源代码

 1 public static Session theSession;
 2 public static UFSession theUfSession;
 3 public static UFUi theUFUi;
 4 
 5 public static int Main()
 6 {
 7     theSession = Session.GetSession();
 8     theUfSession = UFSession.GetUFSession();
 9     theUFUi = theUfSession.Ui;
10 
11     theUFUi.DisplayMessage("Hello,world!", 1);
12 
13     FeatureSigns sign = FeatureSigns.Nullsign;//定义布尔
14     double[] cornet_pt = { 100.0, 0.0, 0.0 };//定义原点
15     string[] edge_len = { "100.0", "100.0", "100.0" };//定义长宽高
16     Tag blk_obj_id = Tag.Null;
17     theUfSession.Modl.CreateBlock1(sign, cornet_pt, edge_len, out blk_obj_id);
18 
19     return (0);
20 }
21 
22 public static int GetUnloadOption(string dummy)
23 {
24     return UFConstants.UF_UNLOAD_IMMEDIATELY;
25 }
26 
27 Caesar卢尚宇
28 2020年2月24日

 

猜你喜欢

转载自www.cnblogs.com/nxopen2018/p/12358851.html