// ! Elimina tutti i fillet
        public static List <string> deleteFillet_(PartDocument oDoc)
        {
            SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition;

            List <string> faceCollToKeep = new List <string>();

            if (oCompDef.Bends.Count > 0)
            {
                Bend oBend = oCompDef.Bends[1];

                FaceCollection oFaceColl = oBend.FrontFaces[1].TangentiallyConnectedFaces;
                oFaceColl.Add(oBend.FrontFaces[1]);

                foreach (Face oFace in oFaceColl)
                {
                    faceCollToKeep.Add(oFace.InternalName);
                }

                NonParametricBaseFeature oBaseFeature = oCompDef.Features.NonParametricBaseFeatures[1];

                oBaseFeature.Edit();

                SurfaceBody basebody = oBaseFeature.BaseSolidBody;

                ObjectCollection oColl = iApp.TransientObjects.CreateObjectCollection();

                foreach (Face f in basebody.Faces)
                {
                    if (faceCollToKeep.Contains(f.InternalName))
                    {
                        if (f.SurfaceType == SurfaceTypeEnum.kCylinderSurface)
                        {
                            oColl.Add(f);
                        }
                    }
                }
                try
                {
                    oBaseFeature.DeleteFaces(oColl);
                    oBaseFeature.ExitEdit();
                }
                catch
                {
                    oBaseFeature.ExitEdit();
                    return(null);
                }
            }

            return(faceCollToKeep);
        }
Beispiel #2
0
        public static void deleteLavorazione(PartDocument oDoc)
        {
            SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition;
            int numeroFacceTan = oCompDef.Bends.Count * 2;

            NonParametricBaseFeature oBaseFeature = oCompDef.Features.NonParametricBaseFeatures[1];

            oBaseFeature.Edit();

            SurfaceBody basebody = oBaseFeature.BaseSolidBody;

            foreach (Face f in basebody.Faces)
            {
                if (f.TangentiallyConnectedFaces.Count == numeroFacceTan)
                {
                    string nameFace = f.InternalName;

                    ObjectCollection oColl = iApp.TransientObjects.CreateObjectCollection();

                    List <string> listName = new List <string>();

                    foreach (EdgeLoop oEdgeLoops in f.EdgeLoops)
                    {
                        Edges oEdges = oEdgeLoops.Edges;

                        string lav = IdentificazioneEntita.whois(oEdges);

                        if (!string.IsNullOrEmpty(lav))
                        {
                            Edge oEdge = oEdges[1];

                            Faces oFaceColl = oEdge.Faces;

                            foreach (Face oFaceLav in oFaceColl)
                            {
                                if (oFaceLav.InternalName != nameFace)
                                {
                                    if (!listName.Contains(oFaceLav.InternalName))
                                    {
                                        oColl.Add(oFaceLav);
                                        listName.Add(oFaceLav.InternalName);
                                    }
                                    foreach (Face oFaceLavTang in oFaceLav.TangentiallyConnectedFaces)
                                    {
                                        if (!listName.Contains(oFaceLavTang.InternalName))
                                        {
                                            oColl.Add(oFaceLavTang);
                                            listName.Add(oFaceLavTang.InternalName);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (oColl.Count > 0)
                    {
                        try
                        {
                            oBaseFeature.DeleteFaces(oColl);
                        }
                        catch
                        {
                        }
                    }
                }
            }
            oBaseFeature.ExitEdit();
        }
        // ! Elimina le lavorazioni
        public static void deleteLavorazione(PartDocument oDoc)
        {
            SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition;

            NonParametricBaseFeature oBaseFeature = oCompDef.Features.NonParametricBaseFeatures[1];

            oBaseFeature.Edit();

            SurfaceBody basebody = oBaseFeature.BaseSolidBody;

            foreach (Face f in basebody.Faces)
            {
                try
                {
                    string nameFaceRif = f.InternalName;

                    ObjectCollection oFaceColl = iApp.TransientObjects.CreateObjectCollection();

                    if (f.EdgeLoops.Count > 1)
                    {
                        foreach (EdgeLoop oEdgeLoop in f.EdgeLoops)
                        {
                            string lavorazione = IdentificazioneEntita.whois(oEdgeLoop.Edges);

                            if (!string.IsNullOrEmpty(lavorazione))
                            {
                                foreach (Face oFaceLav in oEdgeLoop.Edges[1].Faces)
                                {
                                    string nameFaceLav = oFaceLav.InternalName;

                                    if (nameFaceLav != nameFaceRif)
                                    {
                                        oFaceColl.Add(oFaceLav);

                                        foreach (Face oFaceTan in oFaceLav.TangentiallyConnectedFaces)
                                        {
                                            oFaceColl.Add(oFaceTan);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (oFaceColl.Count > 0)
                    {
                        try
                        {
                            oBaseFeature.DeleteFaces(oFaceColl);
                            oBaseFeature.ExitEdit();
                            deleteLavorazione(oDoc);
                        }
                        catch
                        {
                        }
                    }
                }
                catch
                {
                }
            }
            oBaseFeature.ExitEdit();
        }
        // ATTENZIONE NEL CASO CI FOSSERO LAVORAZIONI
        public static List <string> deleteFillet(PartDocument oDoc)
        {
            SheetMetalComponentDefinition oCompDef = (SheetMetalComponentDefinition)oDoc.ComponentDefinition;

            List <string> faceCollToKeep = new List <string>();

            foreach (Face f in oCompDef.SurfaceBodies[1].Faces)
            {
                if (f.SurfaceType == SurfaceTypeEnum.kCylinderSurface)
                {
                    faceCollToKeep.Add(f.InternalName);
                }
            }

            //foreach(Face f in oCompDef.SurfaceBodies[1].Faces)
            //{
            //    if (f.SurfaceType == SurfaceTypeEnum.kCylinderSurface) {
            //        foreach (Face ff in f.TangentiallyConnectedFaces)
            //        {
            //            if (ff.SurfaceType == SurfaceTypeEnum.kCylinderSurface)
            //            {
            //                coloroEntita(oDoc, 255, 0, 0, ff);
            //                faceCollToKeep.Add(ff.InternalName);
            //            }
            //        }
            //        coloroEntita(oDoc, 255, 0, 0, f);
            //        faceCollToKeep.Add(f.InternalName);
            //        break;
            //    }
            //}

            NonParametricBaseFeature oBaseFeature = oCompDef.Features.NonParametricBaseFeatures[1];

            oBaseFeature.Edit();

            SurfaceBody basebody = oBaseFeature.BaseSolidBody;

            ObjectCollection oColl = iApp.TransientObjects.CreateObjectCollection();

            foreach (Face f in basebody.Faces)
            {
                if (faceCollToKeep.Contains(f.InternalName))
                {
                    if (f.SurfaceType == SurfaceTypeEnum.kCylinderSurface)
                    {
                        oColl.Add(f);
                    }
                }
            }

            try
            {
                oBaseFeature.DeleteFaces(oColl);
                oBaseFeature.ExitEdit();
            }
            catch
            {
                oBaseFeature.ExitEdit();
                return(null);
            }

            return(faceCollToKeep);
        }