大家好,今天继续讲解我们的通用方法系列。
下面是今天要介绍的通用方法:
(1)这个通用方法为ug获取选择圆边的圆心
/// <summary>
/// ug获取选择圆边的圆心
/// </summary>
/// <param name="a"></param>
/// <returns></returns>
public static double[] Getyuanxin(Tag a)//获取选择圆边的圆心
{
int type;
theUFSession.Modl.AskEdgeType(a, out type);
double[] p = new double[3];
if (type == 3002)
{
IntPtr uFEval;
theUFSession.Eval.Initialize(a, out uFEval);
UFEval.Arc arc_coords;
theUFSession.Eval.AskArc(uFEval, out arc_coords);
p[0] = arc_coords.center[0];
p[1] = arc_coords.center[1];
p[2] = arc_coords.center[2];
}
return p;
}
(2)这个通用方法为ug获取tag
/// <summary>
/// ug获取tag
/// </summary>
/// <param name="b"></param>
/// <returns></returns>
public static Tag Getplan(Tag b)
{
Tag a=Tag.Null;
Tag[] facelist = null;
theUFSession.Modl.AskEdgeFaces(b, out facelist);
for (int i = 0; i < facelist.Length; i++)
{
int type1;
theUFSession.Modl.AskFaceType(facelist[i], out type1);
if (type1 == 22)
{
a = facelist[i];
}
}
return a;
}
(3)这个通用方法为ug删除孔
/// <summary>
/// ug删除孔
/// </summary>
/// <param name="b"></param>
public static void Deletekong(Tag b)//删除孔
{
NXOpen.Part workPart = theSession.Parts.Work;
Tag[] facelist = null;
theUFSession.Modl.AskEdgeFaces(b, out facelist);
for (int i = 0; i < facelist.Length; i++)
{
int type1;
theUFSession.Modl.AskFaceType(facelist[i], out type1);
if (type1 == 17 || type1 == 16)
{
NXOpen.Face face1 = (NXOpen.Face)NXObjectManager.Get(facelist[i]);
NXOpen.FaceBossPocketFacesRule faceBossPocketFacesRule1;
faceBossPocketFacesRule1 = workPart.ScRuleFactory.CreateRuleFaceBossPocket(face1);
NXOpen.SelectionIntentRule[] rules1 = new SelectionIntentRule[1];
rules1[0] = faceBossPocketFacesRule1;
NXOpen.ScCollector scCollector1 = workPart.ScCollectors.CreateCollector();
scCollector1.ReplaceRules(rules1, false);
TaggedObject[] BB = new TaggedObject[scCollector1.GetObjects().Length];
BB = scCollector1.GetObjects();
Face[] faces = new Face[0];
foreach (var to in BB)
{
Array.Resize(ref faces, faces.Length + 1);
faces[faces.Length - 1] = (Face)to;
}
DeleteFace(faces);
}
}
}
今天要介绍的通用方法就这些,我们下篇文章再见。