Esempio n. 1
0
        public void FileLoad(Session nxSession, string FileDirectory)
        {
            Stpfile = nxSession.Parts.OpenDisplay(FileDirectory, out partloadstatus);
            Stpfile = nxSession.Parts.Work;
            //Stpfile.CoordinateSystems.CreateCoordinateSystem(
            tempbody = nxSession.Parts.Work.Bodies;
            string name = Stpfile.JournalIdentifier.ToString();

            Console.WriteLine(name);
            pBody   = tempbody.ToArray();
            lenBody = pBody.Length;
            NXOpen.Features.Feature[] tempfeature;
            NumOfBodz.Add(FileDirectory, lenBody);//= new string[100];
            e1 = 0;
            h  = 0;
            for (int y = 0; y < lenBody; y++)
            {
                facenameid  = pBody[y].GetFaces();
                tempfeature = pBody[y].GetFeatures();
                string[] featurenames = new string[tempfeature.Length];
                Edge[]   edgesinbody  = pBody[y].GetEdges();
                EdgeVrtx  = new Point3d[2];
                edgenames = new string[edgesinbody.Length];
                for (int r = 0; r < edgesinbody.Length; r++)
                {
                    EdgeVrtx     = new Point3d[2];
                    edgenames[r] = edgesinbody[r].JournalIdentifier.ToString();
                    Point3d a, b;
                    edgesinbody[r].GetVertices(out a, out b);
                    Point3d[] tempEdgeVrtx = new Point3d[2];
                    tempEdgeVrtx[0] = a;
                    tempEdgeVrtx[1] = b;
                    EdgeVrtx        = tempEdgeVrtx.Distinct().ToArray();
                    EdgeVrtxInt.Add(e1, EdgeVrtx);
                    EdgeNames.Add(e1, edgenames[r]);
                    e1++;
                }

                lenFace  = facenameid.Length;
                facename = new string[lenFace];
                for (int x = 0; x < lenFace; x++)
                {
                    facename[x] = facenameid[x].JournalIdentifier.ToString();
                    ///Dictionary Additon;
                    edgeid       = facenameid[x].GetEdges();
                    lenEdge      = edgeid.Length;
                    lenVertx     = 2 * lenEdge;
                    FaceEdgeVrtx = new Point3d[lenVertx];
                    int w2 = 0;
                    for (int w1 = 0; w1 < lenEdge; w1++)
                    {
                        for (; w2 < lenVertx;)
                        {
                            Point3d a, b;
                            edgeid[w1].GetVertices(out a, out b);
                            FaceEdgeVrtx[w2]     = a;
                            FaceEdgeVrtx[w2 + 1] = b;
                            w2 = w2 + 2;
                            break;
                        }
                    }
                    UFaceEdgeVrtx = FaceEdgeVrtx.Distinct().ToArray();
                    PartVrtxInt.Add(h, UFaceEdgeVrtx);
                    h++;
                    VrtxFaceName.Add(UFaceEdgeVrtx, facename[x]);
                }
                for (int f = 0; f < tempfeature.Length; f++)
                {
                    featurenames[f] = tempfeature[f].JournalIdentifier.ToString();
                }
                FeatureNames.Add(y, featurenames[0]);
                Feature2FaceNames.Add(featurenames[0], facename);
                Feature2EdgeNames.Add(featurenames[0], edgenames);
            }
            NXOpen.PartCloseResponses partCloseResponse1;
            partCloseResponse1 = nxSession.Parts.NewPartCloseResponses();
            Stpfile.Close(BasePart.CloseWholeTree.False, NXOpen.BasePart.CloseModified.UseResponses, partCloseResponse1);
            Console.WriteLine("It works");
        }