//각 Constraint에서 사용하는 Master/Slave Part의 ReferenceName을 refCommand 구조체로 리턴
        private refCommand TestRefer(TransCAD.IStdAssemConstraint tConstraint, CTYPE i) //constrain 받아오기
        {
            CTYPE      type   = i;
            refCommand para   = new refCommand();
            refCommand result = new refCommand();

            ReferenceClass.ref_Post m_refer = new ReferenceClass.ref_Post();


            switch (type)
            {
            case CTYPE.Coaxial:
                TransCAD.IStdAssemConstraintCoaxial coax = (TransCAD.IStdAssemConstraintCoaxial)tConstraint;
                Console.WriteLine("Loading Coaxial......................................");

                para.command        = (int)type;
                para.param          = "Axis" + ":(";
                para.MasterPart     = coax.ConstrainedPart.Name;
                para.SlavePart      = coax.ReferencePart.Name;
                para.MasterPart_Ref = coax.ConstrainedGeometry.ReferenceeName;
                para.SlavePart_Ref  = coax.ReferenceGeometry.ReferenceeName;

                break;

            case CTYPE.Incidence:

                TransCAD.IStdAssemConstraintIncidence coin = (TransCAD.IStdAssemConstraintIncidence)tConstraint;
                Console.WriteLine("Loading INCIDENCE......................................");

                para.command        = (int)type;
                para.param          = "";
                para.MasterPart     = coin.ConstrainedPart.Name;
                para.SlavePart      = coin.ReferencePart.Name;
                para.MasterPart_Ref = coin.ConstrainedGeometry.ReferenceeName;
                para.SlavePart_Ref  = coin.ReferenceGeometry.ReferenceeName;


                break;

            /* Mutahar 18-10-09
             * case CTYPE.Angle: //(Surface-Surface)
             * TransCAD.IStdAssemConstraintAngle ang = (TransCAD.IStdAssemConstraintAngle)tConstraint;
             * Console.WriteLine("Loading Angle......................................");
             *
             * para.command = (int)type;
             * para.param = "";
             * para.MasterPart = ang.ConstrainedPart.Name;
             * para.SlavePart = ang.ReferencePart.Name;
             * para.MasterPart_Ref = ang.ConstrainedGeometry.ReferenceeName;
             * para.SlavePart_Ref = ang.ReferenceGeometry.ReferenceeName;
             * Angle Value?
             *
             * break;
             * case CTYPE.Distance: //(Surface-Surface)
             * TransCAD.IStdAssemConstraintCoaxial Dist = (TransCAD.IStdAssemConstraintDistance)tConstraint;
             * Console.WriteLine("Loading Distance......................................");
             *
             * para.command = (int)type;
             * para.param = "";
             * para.MasterPart = dist.ConstrainedPart.Name;
             * para.SlavePart = dist.ReferencePart.Name;
             * para.MasterPart_Ref = dist.ConstrainedGeometry.ReferenceeName;
             * para.SlavePart_Ref = dist.ReferenceGeometry.ReferenceeName;
             * Offset Value?
             *
             * break;
             */

            default:
                Console.WriteLine("Anything........");
                break;
            }
            Console.WriteLine("////////////////////////////////////////////////////////////////////////");
            result = m_refer.ConvertRefPost(para);

            Console.WriteLine("////////////////////////////////////////////////////////////////////////");
            Console.WriteLine("ConsNum : " + result.command.ToString());
            Console.WriteLine("master : " + result.MasterPart_Ref);
            Console.WriteLine("slave : " + result.SlavePart_Ref);
            Console.WriteLine("////////////////////////////////////////////////////////////////////////");

            return(result);
        }
示例#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("");
        }