Calculation of Face Area

All topics about specific development with COM interface, LIP language, API in VB, ...

Moderators: remi77, jacs, Daniel

nikhilruikar
Private First Class
Private First Class
Posts: 18
Joined: Tue Sep 08, 2015 11:04 am
TopSolid Module: TopSolid'Design
TopSolid Version: 6.25

Calculation of Face Area

Unread post by nikhilruikar »

Hi Team,

I have a shape that has 6 faces.
I want to find the ElementId of the face with maximum area.
For this purpose, I need to be able to calculate area of each face.

I searched the API help but, couldn't find anything.
Does anybody know anything about it?

Regards,
Nikhil
gmanucci
Master Corporal
Master Corporal
Posts: 49
Joined: Tue Sep 29, 2015 2:48 pm
TopSolid Module: TopSolid'Cam
TopSolid Version: 6.26

Re: Calculation of Face Area

Unread post by gmanucci »

There is two kinds of Elements

the ElementId (where is stored the value of the shape)
and the ElementItemId (where is stored Items from ElementId, like faces)

You want to get the maximum area of just one ElementId or get the maximum area of each shapes?
nikhilruikar
Private First Class
Private First Class
Posts: 18
Joined: Tue Sep 08, 2015 11:04 am
TopSolid Module: TopSolid'Design
TopSolid Version: 6.25

Re: Calculation of Face Area

Unread post by nikhilruikar »

ElementItemId

I want to find the ElementItemId of the face that has max area.
gmanucci
Master Corporal
Master Corporal
Posts: 49
Joined: Tue Sep 29, 2015 2:48 pm
TopSolid Module: TopSolid'Cam
TopSolid Version: 6.26

Re: Calculation of Face Area

Unread post by gmanucci »

ok, but will look into all shapes or in only one selected shape?
nikhilruikar
Private First Class
Private First Class
Posts: 18
Joined: Tue Sep 08, 2015 11:04 am
TopSolid Module: TopSolid'Design
TopSolid Version: 6.25

Re: Calculation of Face Area

Unread post by nikhilruikar »

Just one shape.

GetallFaces of that shape.
Find area of each face.
gmanucci
Master Corporal
Master Corporal
Posts: 49
Joined: Tue Sep 29, 2015 2:48 pm
TopSolid Module: TopSolid'Cam
TopSolid Version: 6.26

Re: Calculation of Face Area

Unread post by gmanucci »

i'm not finding an way to get the areas ):

i got the faces, edges, etc. but not the areas ):
nikhilruikar
Private First Class
Private First Class
Posts: 18
Joined: Tue Sep 08, 2015 11:04 am
TopSolid Module: TopSolid'Design
TopSolid Version: 6.25

Re: Calculation of Face Area

Unread post by nikhilruikar »

Same here. :(

My aim is to determine the face(Only ElementItemId) that has max area. It's okay if I am unable to calculate the exact area value.
I can think of another way of doing this,

I will process only Planar faces.
I can get a planar face & its edges.
Then I can get length of each edge. I will add the edge lengths for a face & get a number.
Then repeat the same for all faces.

This should look like,
Face1: Sum of Edge Lengths = 100
Face2: Sum of Edge Lengths = 150
Face3: Sum of Edge Lengths = 200

I think that the face with max sum of edge lengths must be the face with max area.
This way I can determine the ElementItemId of the face.

Can anyone confirm that this will give the same result?
I am not quite sure.
gmanucci
Master Corporal
Master Corporal
Posts: 49
Joined: Tue Sep 29, 2015 2:48 pm
TopSolid Module: TopSolid'Cam
TopSolid Version: 6.26

Re: Calculation of Face Area

Unread post by gmanucci »

I guess if you have an rectangular shape, with small thickness you'll have a small area but an big perimeter...
nikhilruikar
Private First Class
Private First Class
Posts: 18
Joined: Tue Sep 08, 2015 11:04 am
TopSolid Module: TopSolid'Design
TopSolid Version: 6.25

Re: Calculation of Face Area

Unread post by nikhilruikar »

Right.

I think this should work for me.
nikhilruikar
Private First Class
Private First Class
Posts: 18
Joined: Tue Sep 08, 2015 11:04 am
TopSolid Module: TopSolid'Design
TopSolid Version: 6.25

Re: Calculation of Face Area

Unread post by nikhilruikar »

But, It would be best if I can actually get the face area from an API. :P
gmanucci
Master Corporal
Master Corporal
Posts: 49
Joined: Tue Sep 29, 2015 2:48 pm
TopSolid Module: TopSolid'Cam
TopSolid Version: 6.26

Re: Calculation of Face Area

Unread post by gmanucci »

of course!

i'm thinking about it, and i don't know how to proceed with an face that have an boss (will add edges, and then will raise our "perimeter")
nikhilruikar
Private First Class
Private First Class
Posts: 18
Joined: Tue Sep 08, 2015 11:04 am
TopSolid Module: TopSolid'Design
TopSolid Version: 6.25

Re: Calculation of Face Area

Unread post by nikhilruikar »

Right.
I thought of it....I tried to get only the outer loop on the face.
But for some reason, the IShapes.GetLoopType() & IShapes.GetLoopEdges() APIs are throwing exception even if IShapes.GetFaceLoops() gives me 2 loops.

I think I am missing something while using these APIs as they are crashing with the exception 'Invalid loop identifier'.

I also tried using the IShapes.GetBoundaryEdges() API but, it is returning count 0.
Mark Oostveen
Chief
Chief
Posts: 107
Joined: Mon Mar 26, 2007 9:40 am
TopSolid Module: TopSolid'Cam
TopSolid Version: 6.26
Location: The netherlands
Contact:

Re: Calculation of Face Area

Unread post by Mark Oostveen »

Of course if you shape is a solid there are no boundaries. It is closed [emoji2]
Getfaceloop with the faceId seems to me the most logic way.

Can I see a picture of the shape and it's face to analyse?
nikhilruikar
Private First Class
Private First Class
Posts: 18
Joined: Tue Sep 08, 2015 11:04 am
TopSolid Module: TopSolid'Design
TopSolid Version: 6.25

Re: Calculation of Face Area

Unread post by nikhilruikar »

PFA the shape & selected face image.
It's a solid.

IShapes.GetFaceLoops() gives me 2 loop IDs.
But, IShapes.GetLoopEdges() API crashes. Also, I can't understand why this API requires shape ElementId as parameter instead of face elementItemId ?

How can I get the face loop edges?
BossPart.png
Attachments
BossPart2.png
Mark Oostveen
Chief
Chief
Posts: 107
Joined: Mon Mar 26, 2007 9:40 am
TopSolid Module: TopSolid'Cam
TopSolid Version: 6.26
Location: The netherlands
Contact:

Re: Calculation of Face Area

Unread post by Mark Oostveen »

A face is a shape. A shape can be a Solid or a surface. And thus it can be a single face surface or a multi face surface. That's why you need to give a Shape I'd.

What is wrong than with the Ishape.GetFaceLoops ? You have your edges. Can you check the length to get the smallest of both, that's the one you want. Isn't it?
Post Reply