Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Finding solid face and edge

3 REPLIES 3
Reply
Message 1 of 4
NachitoMax
470 Views, 3 Replies

Finding solid face and edge

Hi

Been trying to this, can't figure it out... I have a bunch of solid parts. Let's say they are 600 x 600 x 20mm thick. I need to be able to highlight all of the edges only (600 x 20) and ignore the largest faces. I'm not talking about the edge lines, I'm talking about the long thin faces. Think of an mdf panel and I want edging on them.

Can this be done? I can find the largest face but not all of the thin faces .

I can use vba and .net.


Thanks in advance

Nige

Nacho

Automation & Design Engineer

Inventor Programmer (C#, VB.Net / iLogic)


EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: NachitoMax

Hi, Nige,

 

If I understand you, you want to highlight four faces (600x20), but not to highlight two faces (600x600).

 

Did you tried with Faces object in SufaceBodies under PartDocumentDescription?

 

Best regards,

Nedeljko.

 

Message 3 of 4
NachitoMax
in reply to: Anonymous

Hi

The other way. I want to highlight the 2 600 x 600 faces

Thanks

Nacho

Automation & Design Engineer

Inventor Programmer (C#, VB.Net / iLogic)


EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 4 of 4
rjay75
in reply to: NachitoMax

Attached is some code to demonstrate how you might go about it. (Hasn't been tested.)

 

    public class ShowFaces
    {
        //Compare Face by area
        public static int CompareByArea(Face face1, Face face2)
        {
            double area1 = face1.Evaluator.Area;
            double area2 = face2.Evaluator.Area;
 
            if (area1 < area2)
            {
                return -1;
            }
            else if (area1 > area2)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
 
        //Get Panel Surfaces - Returns list of Panels
        public static ObjectCollection GetPanelSurfaces(SurfaceBody body)
        {
            Inventor.Application _appInventor = (Inventor.Application)body.Application;
            Faces faces = body.Faces;
            List<Face> lstFaces = new List<Face>((IEnumerable<Face>)faces);
            lstFaces.Sort(CompareByArea);
            ObjectCollection objCol = _appInventor.TransientObjects.CreateObjectCollection();
            objCol.Add(lstFaces[0]);
            objCol.Add(lstFaces[1]);
            return objCol;
        }
 
        //Highlight entities
        public static void HighlightEntities(PartDocument ivDoc, ObjectCollection objCol)
        {
            if ((objCol != null) && (objCol.Count > 0))
            {
                Inventor.Application _appInventor = (Application)ivDoc.Parent;
                HighlightSet hs = ivDoc.CreateHighlightSet();
                Inventor.Color oRed = _appInventor.TransientObjects.CreateColor(255, 0, 0);
                oRed.Opacity = 0.8;
                foreach (object obj in objCol)
                {
                    hs.AddItem(obj);
                }
            }
        }
 
        //Highlight the largest panels.
        public static void HighlightLargePanels(PartDocument pDoc)
        {
            SurfaceBodies sbs = pDoc.ComponentDefinition.SurfaceBodies;
            foreach (SurfaceBody sb in sbs)
            {
                HighlightEntities(pDoc, GetPanelSurfaces(sb));
            }
        }
    }

 

Basically get the two largets surfaces on a surface body. Add them to a HighlightSet.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report