[Scmold]UG二次开发入门实例
论坛上很难看到有关UG二次开发的贴,今天刚好有空发个简单的例子,活跃一下论坛的气氛,下面是用C#在UG中的二次开发的简单实例,[创建一个正方体],希望可以帮到需要入门的朋友,高手请勿抛砖...using System;
public class Program
{
private static Session theSession;
public static Program theProgram;
public static bool isDisposeCalled;
public Program()
{
try
{
theSession = Session.GetSession();
isDisposeCalled = false;
}
catch (NXOpen.NXException ex)
{
UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
}
}
public static int Main(string[] args)
{
int retValue = 0;
try
{
theProgram = new Program();
Part thePart = theSession.Parts.Work;
NXOpen.Features.Feature block = null;
NXOpen.Features.BlockFeatureBuilder theBuilder = thePart.Features.CreateBlockFeatureBuilder(block);
NXOpen.Point3d basePoint = new Point3d(100f, 100f, 100f);
theBuilder.SetOriginAndLengths(basePoint, "0", "0", "0");
theBuilder.Commit(); UI.GetUI().NXMessageBox.Show("", NXMessageBox.DialogType.Information, "你已成功完成了第一个二次开发程序!");
theProgram.Dispose();
}
catch (NXOpen.NXException ex)
{
UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
}
return retValue;
}
public void Dispose()
{
try
{
if (isDisposeCalled == false)
{
//Add your application code here
}
isDisposeCalled = true;
}
catch (NXOpen.NXException ex)
{
UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
}
}
public static int GetUnloadOption(string arg)
{
return System.Convert.ToInt32(Session.LibraryUnloadOption.AtTermination);
}
} 下面是用C++实现遍历特征的部分代码复制代码 刚入门学习 现在在学GRIP C+实在是太难了点 可有教程吗,都是同行 回帖是一种美德!感谢楼主的无私分享 谢谢 谢谢楼主分享 谢谢楼主分享 ,有更全的吗
页:
[1]