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: 

Getting the surface area of a face (like the measure tool) in Code

2 REPLIES 2
Reply
Message 1 of 3
NachitoMax
512 Views, 2 Replies

Getting the surface area of a face (like the measure tool) in Code

Hi

 

i need to be able to get the surface area of a part. i can get it using the measure tool and selecting the 'Measure Area' command but can i get the value i need via code only?

 

area.JPG

 

i actually need to iterate all faces on a part to find the largest one. 

 

Does anyboby have any ideas or can help?

 

 

 

Thanks

 

 

Nigel

 

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.


2 REPLIES 2
Message 2 of 3
nmunro
in reply to: NachitoMax

 

Something like so (VB.NET). Covers parts with multiple solid bodies.

 

Dim doc As PartDocument = Nothing

Dim bodies As SurfaceBodies = Nothing

Dim faces As Faces = Nothing

Dim maxArea AsDouble = 0.0

Dim faceArea AsDouble = 0.0

Dim bigFace As Face = Nothing

 

doc = <get a reference to part document>

bodies = doc.ComponentDefinition.SurfaceBodies

For Each body As SurfaceBody In bodies

    For Each bodyFace As Face In body.Faces

        faceArea = bodyFace.Evaluator.Area

        If faceArea > maxArea Then

            bigFace = bodyFace

            maxArea = faceArea

        End If

    Next

Next

        


https://c3mcad.com

Message 3 of 3
NachitoMax
in reply to: nmunro

Hi

Thanks for that. I had managed to muster up a routine and I had found the evaluator.area about 2 hours ago. I made a variable to store the area on a condition that it could only be stored if the value was higher than the previously stored area. That way I would filter the highest (largest) face. Your code looks smaller than mine 🙂

I added in a small routine to highlight the largest face at the end but I'm struggling with making it a selected face 🙂


Thanks for the code





Nigel

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.


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

Post to forums  

Autodesk Design & Make Report