示例#1
0
        public void FindtheEdgeName(Session nxSession)
        {
            var getName = new GeometricNames();

            for (int i = 0; i < 2; i++)
            {
                if (partOne[i].Length == 2)
                {
                    CircularFace1 = partOne[i];
                }
                if (partTwo[i].Length == 2)
                {
                    CircularFace2 = partTwo[i];
                }
            }

            Point3d[] point1 = new Point3d[1];
            point1[0] = toOne(CircularFace1, partOne);
            Point3d[] point2 = new Point3d[1];
            point2[0] = toOne(CircularFace2, partTwo);
            var filedir = new NewNXfile();

            filedir.partDir("RotationPart");
            filedir.partDir("Body");
            string fileDirect1   = "D:\\Macro\\A1post\\RotationPart.prt";
            string consgeomname1 = getName.LoadName(nxSession, point1, filedir.partDir("RotationPart"), "Edge");
            string fileDirect2   = "D:\\Macro\\A1post\\Body.prt";
            string consgeomname2 = getName.LoadName(nxSession, point2, filedir.partDir("Body"), "Edge");

            EdgeNames    = new string[2];
            EdgeNames[0] = consgeomname1;
            EdgeNames[1] = consgeomname2;
        }
示例#2
0
        public void FromTransCAD(Session nxSession)
        {
            Console.WriteLine("Number fo Const" + tAssem.Constraints.Count);
            TransCAD.IStdAssemConstraint[]       GetConstraints = new TransCAD.IStdAssemConstraint[tAssem.Constraints.Count];
            TransCAD.StdAssemConstraintCoaxial   ConstraintCoaxial;
            TransCAD.StdAssemConstraintIncidence ConstraintIncidence;
            string[] ConsPrtName = new string[tAssem.Constraints.Count];
            string[] ConsGeoName = new string[tAssem.Constraints.Count];
            string[] RefPrtName  = new string[tAssem.Constraints.Count];
            string[] RefGeoName  = new string[tAssem.Constraints.Count];


            for (int i = 0; i < tAssem.Constraints.Count; i++)
            {
                GetConstraints[i] = tAssem.Constraints.get_Constraint(i + 1);
                if (GetConstraints[i].Name == "Coaxial")
                {
                    ConstraintCoaxial = (TransCAD.StdAssemConstraintCoaxial)GetConstraints[i];
                    ConsPrtName[i]    = ConstraintCoaxial.ConstrainedPart.Name;
                    if (ConstraintCoaxial.ConstrainedGeometry.ReferenceeName.Contains("#"))
                    {
                        string tempstr = ConstraintCoaxial.ConstrainedGeometry.ReferenceeName;
                        Console.WriteLine("Constains #");
                        int z = tempstr.IndexOf('#');
                        if (z >= 0)
                        {
                            tempstr = tempstr.Substring(z + 1);
                        }
                        ConsGeoName[i] = tempstr;
                    }
                    else
                    {
                        ConsGeoName[i] = ConstraintCoaxial.ConstrainedGeometry.ReferenceeName;
                    }

                    RefPrtName[i] = ConstraintCoaxial.ReferencePart.Name;
                    if (ConstraintCoaxial.ReferenceGeometry.ReferenceeName.Contains("#"))
                    {
                        string tempstr = ConstraintCoaxial.ReferenceGeometry.ReferenceeName;
                        Console.WriteLine("Constains #");
                        int z = tempstr.IndexOf('#');
                        if (z >= 0)
                        {
                            tempstr = tempstr.Substring(z + 1);
                        }
                        RefGeoName[i] = tempstr;
                    }
                    else
                    {
                        RefGeoName[i] = ConstraintCoaxial.ReferenceGeometry.ReferenceeName;
                    }
                }
                else if (GetConstraints[i].Name == "Incidence")
                {
                    ConstraintIncidence = (TransCAD.StdAssemConstraintIncidence)GetConstraints[i];
                    if (ConstraintIncidence.ConstrainedGeometry.ReferenceeName.Contains("#"))
                    {
                        Console.WriteLine("Constains #");
                    }
                    ConsPrtName[i] = ConstraintIncidence.ConstrainedPart.Name;
                    if (ConstraintIncidence.ReferenceGeometry.ReferenceeName.Contains("#"))
                    {
                        Console.WriteLine("Constains #");
                    }
                    ConsGeoName[i] = ConstraintIncidence.ConstrainedGeometry.ReferenceeName;
                    RefPrtName[i]  = ConstraintIncidence.ReferencePart.Name;
                    RefGeoName[i]  = ConstraintIncidence.ReferenceGeometry.ReferenceeName;
                }
                Console.WriteLine("Constraints Part" + i + " Name:: " + ConsPrtName[i]);
                Console.WriteLine("Constraints Geometry" + i + "Geometry:: " + ConsGeoName[i]);
                Console.WriteLine("Reference Part" + i + " Name:: " + RefPrtName[i]);
                Console.WriteLine("Reference Geometry" + i + "Geometry:: " + RefGeoName[i]);
            }
            int p = 0, q = 0;

            ConstNames1    = new string[2];
            ConstNames2    = new string[2];
            constNamesTemp = new string[2];
            ConsNames      = new List <string>();
            PartNamestoNX  = new List <string>();
            for (int i = 0; i < 2; i++)
            {
                var    filedir        = new NewNXfile();
                string constraintName = GetConstraints[i].Name;
                constNamesTemp[i] = constraintName;

                string partnam = tcad_PartList[i].Name;
                double ox, oy, oz, xx, xy, xz, yx, yy, yz;
                tcad_PartList[i].GetPlacement(out ox, out oy, out oz, out xx, out xy, out xz, out yx, out yy, out yz);
                Point3d tcad_Position      = new Point3d(ox, oy, oz);
                Point3d tcad_X_Orientation = new Point3d(xx, xy, xz);
                Point3d tcad_Y_Orientation = new Point3d(yx, yy, yz);
                var     getName            = new GeometricNames();
                Console.WriteLine(partnam);
                int      facecount = tcad_PartList[i].Solid.Faces.Count;
                string[] partname  = new string[tcad_PartList[i].Solid.Faces.Count + 1];

                for (int i1 = 1; i1 <= facecount; i1++)
                {
                    partname[i1] = tcad_PartList[i].Solid.Faces[i1].Name;
                }
                string[] tempname = partname;
                for (int l = 0; l < 2; l++)
                {
                    for (int k = 1; k < facecount + 1; k++)
                    {
                        name = tcad_PartList[i].Solid.Faces[k].Name;

                        if ((ConsGeoName[l].Contains(name)) & (p <= 1))
                        {
                            Console.WriteLine("The maching face in " + partnam + " is " + k + " for constraint " + l);
                            Console.WriteLine(name);

                            int numVertex = tcad_PartList[i].Solid.Faces[k].Vertices.Count;
                            Console.WriteLine("Number of Vertices in Constrained Geometry" + numVertex);
                            TcadCV1  = new Point3d[numVertex];
                            TcadCV01 = new Point3d[numVertex];
                            int n = 0;
                            {
                                Console.WriteLine("Constrainted Geometry is :::");
                                for (int m = 1; m < numVertex + 1; m++)
                                {
                                    for (; n < numVertex;)
                                    {
                                        Point3d         tempTV;
                                        TransCAD.Vertex tv = tcad_PartList[i].Solid.Faces[k].Vertices[m];
                                        Console.WriteLine(" (" + tv.X + "," + tv.Y + "," + tv.z + ") ");
                                        tempTV.X    = tv.X;
                                        tempTV.Y    = tv.Y;
                                        tempTV.Z    = tv.z;
                                        TcadCV01[n] = tempTV;
                                        TcadCV1[n]  = OrientedTranslated(tempTV, tcad_Position, tcad_X_Orientation, tcad_Y_Orientation);
                                        //TcadCV1[n].X = tv.X;
                                        //TcadCV1[n].Y = tv.Y;
                                        //TcadCV1[n].Z = tv.z;

                                        n = n + 1;
                                        break;
                                    }
                                }
                            }
                            partOne.Add(p, TcadCV1);
                            string fileDirect    = "D:\\Macro\\A1post\\RotationPart.prt";
                            string consgeomname1 = getName.LoadName(nxSession, TcadCV01, filedir.partDir(partnam), "Face");
                            //ConstNames1[p] = consgeomname1;
                            p = p + 1;
                            ConsNames.Add(consgeomname1);
                            PartNamestoNX.Add(partnam);
                            break;
                        }
                        if (RefGeoName[l].Contains(name))
                        {
                            Console.WriteLine("The matching face in " + partnam + " is " + k + " for constraint " + l);
                            Console.WriteLine(name);
                            Console.WriteLine("Reference Geometry is :::");
                            int numVertex = tcad_PartList[i].Solid.Faces[k].Vertices.Count;
                            TcadCV2  = new Point3d[numVertex];
                            TcadCV02 = new Point3d[numVertex];
                            int n = 0;
                            Console.WriteLine("Number of Vertices in Reference Geometry" + numVertex);
                            {
                                for (int m = 1; m < numVertex + 1; m++)
                                {
                                    for (; n < numVertex;)
                                    {
                                        Point3d         tempTV;
                                        TransCAD.Vertex tv = tcad_PartList[i].Solid.Faces[k].Vertices[m];
                                        Console.WriteLine(" (" + tv.X + "," + tv.Y + "," + tv.z + ") ");
                                        tempTV.X    = tv.X;
                                        tempTV.Y    = tv.Y;
                                        tempTV.Z    = tv.z;
                                        TcadCV02[n] = tempTV;
                                        TcadCV2[n]  = OrientedTranslated(tempTV, tcad_Position, tcad_X_Orientation, tcad_Y_Orientation);
                                        //TcadCV2[n].X = tv.X;
                                        //TcadCV2[n].Y = tv.Y;
                                        //TcadCV2[n].Z = tv.z;
                                        n = n + 1;
                                        break;
                                    }
                                }
                            }
                            partTwo.Add(q, TcadCV2);
                            string fileDirect1   = "D:\\Macro\\A1post\\Body.prt";
                            string consgeomname2 = getName.LoadName(nxSession, TcadCV02, filedir.partDir(partnam), "Face");
                            Console.WriteLine("Value of tCADlength " + TcadCV2.Length);
                            Console.WriteLine("Value of P:::::" + p);
                            //ConstNames2[q] = consgeomname2;
                            q = q + 1;
                            ConsNames.Add(consgeomname2);
                            PartNamestoNX.Add(partnam);
                            break;
                        }
                    }
                }
            }
            p = 0;
            q = 0;
            for (int z1 = 0; z1 < ConsNames.Count; z1++)
            {
                for (int z2 = 0; z2 < partname.Length; z2++)
                {
                    if (PartNamestoNX[z1].Contains(partname[z2]))
                    {
                        ConstNames1[p] = ConsNames[z1];
                        p = p + 1;
                        break;
                    }
                    else
                    {
                        ConstNames2[q] = ConsNames[z1];
                        q = q + 1;
                        break;
                    }
                }
            }
            Console.WriteLine("");
        }