UG NX二次开发(C#)-批处理-导入Part文件
Posted GimiGimmy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UG NX二次开发(C#)-批处理-导入Part文件相关的知识,希望对你有一定的参考价值。
/// <summary>
/// 导入Part文件
/// </summary>
/// <param name="importFileFullPath">part文件全路径</param>
/// <param name="flag">无用,是为了区别NXOpen的函数</param>
public static void ImportPartFun(string importFileFullPath,bool flag)
ImportPartModes importPartModes = new ImportPartModes();
importPartModes.layer_mode = 0;
importPartModes.group_mode = 0;
importPartModes.layer_mode = 1;
importPartModes.view_mode = 0;
importPartModes.view_mode = 1;
importPartModes.cam_mode = false;
importPartModes.csys_mode = 1;
double[] csys = new double[6] 1, 0, 0, 0, 1, 0;
double[] point = new double[] 0,0,0 ;
Tag tag = new Tag();
double scale = 1.0;
uFPart.Import(importFileFullPath,ref importPartModes,csys,point,scale, out tag);
/// <summary>
/// 导入Part文件
/// </summary>
/// <param name="importFileFullPath">part文件全路径</param>
public static void ImportPartFun(string importFileFullPath)
NXOpen.PartImporter partImporter1;
partImporter1 = workPart.ImportManager.CreatePartImporter();
partImporter1.FileName = importFileFullPath;
partImporter1.Scale = 1.0;
partImporter1.CreateNamedGroup = false;
partImporter1.ImportViews = false;
partImporter1.ImportCamObjects = false;
partImporter1.LayerOption = NXOpen.PartImporter.LayerOptionType.Work;
partImporter1.DestinationCoordinateSystemSpecification = NXOpen.PartImporter.DestinationCoordinateSystemSpecificationType.Work;
NXOpen.Matrix3x3 element1 = new NXOpen.Matrix3x3();
element1.Xx = 1.0;
element1.Xy = 0.0;
element1.Xz = 0.0;
element1.Yx = 0.0;
element1.Yy = 1.0;
element1.Yz = 0.0;
element1.Zx = 0.0;
element1.Zy = 0.0;
element1.Zz = 1.0;
NXOpen.NXMatrix nXMatrix1;
nXMatrix1 = workPart.NXMatrices.Create(element1);
partImporter1.DestinationCoordinateSystem = nXMatrix1;
NXOpen.Point3d destinationPoint1 = new NXOpen.Point3d(0.0, 0.0, 0.0);
partImporter1.DestinationPoint = destinationPoint1;
NXOpen.NXObject nXObject1;
nXObject1 = partImporter1.Commit();
partImporter1.Destroy();
以上是关于UG NX二次开发(C#)-批处理-导入Part文件的主要内容,如果未能解决你的问题,请参考以下文章
UG NX二次开发(C#)-Part-根据模型名称获取part的对象