外部exe启动UG NX

1 用.net2003建立一个控制台应用程序 2 将目录ugii\managed下除ManagedLoader.dll外的dll文件加入到你的工程里面的References 3 将下面的代码复制到你的Main函数里面 theSession = Session.GetSession(); theSession.Parts.NewDisplay("d:\\1.prt",NXOpen.Part.Units.Millimeters); NXOpen.Features.Feature nullFeatures_Feature = null; NXOpen.Part pp=theSession.Parts.Work; myblock = pp.Features.CreateBlockFeatureBuilder(nullFeatures_Feature) ; Point3d ps = new Point3d(0.0, 0.0, 0.0); myblock.SetOriginAndLengths(ps, "100", "100", "100"); myblock.CommitFeature(); NXOpen.PartSaveStatus status; theSession.Parts.Work.Save(NXOpen.Part.SaveComponents.True,NXOpen.Part.CloseAfterSave.False, out status); 4 修改项目的属性,将输出文件定位到ugii目录 5 编译直接运行生成的exe文件(不需要启动UG) 6 在d:\下会生成文件1.prt using System; using NXOpen; using NXOpen.UF; namespace drawBlock { class Class1 { public static Session theSession; public static UFSession theUFSession; static void Main(string[] args) { theSession = Session.GetSession(); theUFSession = UFSession.GetUFSession(); theSession.Parts.NewDisplay("d:\\1.prt",NXOpen.Part.Units.Millimeters); NXOpen.Features.Feature nullFeatures_Feature = null; NXOpen.Part pp=theSession.Parts.Work; NXOpen.Features.BlockFeatureBuilder myblock=pp.Features.CreateBlockFeatureBuilder(nullFeatures_Feature) ; Point3d ps = new Point3d(0.0, 0.0, 0.0); myblock.SetOriginAndLengths(ps, "100", "100", "100"); myblock.CommitFeature(); NXOpen.PartSaveStatus status; theSession.Parts.Work.Save(NXOpen.Part.SaveComponents.True,NXOpen.Part.CloseAfterSave.False, out status); } } }

转载于:https://www.cnblogs.com/yyFisheep/archive/2012/11/08/2760125.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值