用C#对UG进行二次开发.请问如何在C#界面中调用UG的自定义界面?
publicvoidCreateBlock1(){SessiontheSession=Session.GetSession();PartworkPart=theSessi...
public void CreateBlock1()
{
Session theSession = Session.GetSession();
Part workPart = theSession.Parts.Work;
Part displayPart = theSession.Parts.Display;
NXOpen.Features.Feature nullFeatures_Feature = null;
NXOpen.Features.BlockFeatureBuilder blockFeatureBuilder1;
blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullFeatures_Feature);
blockFeatureBuilder1.BooleanOption.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
Body[] targetBodies1 = new Body[1];
Body nullBody = null;
targetBodies1[0] = nullBody;
blockFeatureBuilder1.BooleanOption.SetTargetBodies(targetBodies1);
blockFeatureBuilder1.Type = NXOpen.Features.BlockFeatureBuilder.Types.OriginAndEdgeLengths;
Point point1;
point1 = blockFeatureBuilder1.OriginPoint;
blockFeatureBuilder1.OriginPoint = point1;
double L = createblockRealL.ItemValue;
double W = createblockRealW.ItemValue;
double H = createblockRealH.ItemValue;
Point3d originPoint1 = new Point3d(0.0, 0.0, 0.0);
blockFeatureBuilder1.SetOriginAndLengths(originPoint1, L.ToString(), W.ToString(), H.ToString());
blockFeatureBuilder1.SetBooleanOperationAndTarget(NXOpen.Features.Feature.BooleanType.Create, nullBody);
NXOpen.Features.Feature feature1;
feature1 = blockFeatureBuilder1.CommitFeature();
blockFeatureBuilder1.Destroy();
}
public NXOpen.UIStyler.DialogState ok_cb(NXOpen.UIStyler.StylerEvent eventObject)
{
try
{
CreateBlock1();
}
catch (NXOpen.NXException ex)
{
theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message);
}
return NXOpen.UIStyler.DialogState.ExitDialog;
}
如上,我用UG的UI样式编辑器做一个长方体用于输入 长\宽\高的界面,在生成的*.dlg中用0K_cb函数调用长方体创建模块,但在UG中执行没反应,是什么原因呢? 展开
{
Session theSession = Session.GetSession();
Part workPart = theSession.Parts.Work;
Part displayPart = theSession.Parts.Display;
NXOpen.Features.Feature nullFeatures_Feature = null;
NXOpen.Features.BlockFeatureBuilder blockFeatureBuilder1;
blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullFeatures_Feature);
blockFeatureBuilder1.BooleanOption.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;
Body[] targetBodies1 = new Body[1];
Body nullBody = null;
targetBodies1[0] = nullBody;
blockFeatureBuilder1.BooleanOption.SetTargetBodies(targetBodies1);
blockFeatureBuilder1.Type = NXOpen.Features.BlockFeatureBuilder.Types.OriginAndEdgeLengths;
Point point1;
point1 = blockFeatureBuilder1.OriginPoint;
blockFeatureBuilder1.OriginPoint = point1;
double L = createblockRealL.ItemValue;
double W = createblockRealW.ItemValue;
double H = createblockRealH.ItemValue;
Point3d originPoint1 = new Point3d(0.0, 0.0, 0.0);
blockFeatureBuilder1.SetOriginAndLengths(originPoint1, L.ToString(), W.ToString(), H.ToString());
blockFeatureBuilder1.SetBooleanOperationAndTarget(NXOpen.Features.Feature.BooleanType.Create, nullBody);
NXOpen.Features.Feature feature1;
feature1 = blockFeatureBuilder1.CommitFeature();
blockFeatureBuilder1.Destroy();
}
public NXOpen.UIStyler.DialogState ok_cb(NXOpen.UIStyler.StylerEvent eventObject)
{
try
{
CreateBlock1();
}
catch (NXOpen.NXException ex)
{
theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message);
}
return NXOpen.UIStyler.DialogState.ExitDialog;
}
如上,我用UG的UI样式编辑器做一个长方体用于输入 长\宽\高的界面,在生成的*.dlg中用0K_cb函数调用长方体创建模块,但在UG中执行没反应,是什么原因呢? 展开
1个回答
展开全部
在编译的时候有没有成功,需要建立三个文件夹,在环境变量中指定自定义路径,编译成功的话应该没问题的
追问
你好,编译是成功了的,也建立好了文件夹(startup(此文件夹存放*men 、*dll)、application(存放*dlg))。路径也指定了。在UG中能调用UGStyler做的对话框,但输入数据,单击确定按钮却没反应。确定按钮是指定了回调函数(ok_cb)在此函数下调用的CreateBlock1()。这个是什么原因呢?你有这样的一个简单实例吗?如果可以的话,能不能发一个到fyywhy@163.com.谢谢!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询