Calculation of Face Area

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

Moderators: remi77, Daniel, jacs

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

Calculation of Face Area

Unread post by nikhilruikar » Mon Oct 19, 2015 2:34 pm

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: 7.6

Re: Calculation of Face Area

Unread post by gmanucci » Mon Oct 19, 2015 4:32 pm

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: 7.5

Re: Calculation of Face Area

Unread post by nikhilruikar » Tue Oct 20, 2015 7:46 am

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: 7.6

Re: Calculation of Face Area

Unread post by gmanucci » Tue Oct 20, 2015 12:27 pm

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: 7.5

Re: Calculation of Face Area

Unread post by nikhilruikar » Tue Oct 20, 2015 2:11 pm

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: 7.6

Re: Calculation of Face Area

Unread post by gmanucci » Tue Oct 20, 2015 5:07 pm

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: 7.5

Re: Calculation of Face Area

Unread post by nikhilruikar » Wed Oct 21, 2015 8:20 am

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: 7.6

Re: Calculation of Face Area

Unread post by gmanucci » Wed Oct 21, 2015 11:18 am

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: 7.5

Re: Calculation of Face Area

Unread post by nikhilruikar » Wed Oct 21, 2015 11:57 am

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: 7.5

Re: Calculation of Face Area

Unread post by nikhilruikar » Wed Oct 21, 2015 1:57 pm

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: 7.6

Re: Calculation of Face Area

Unread post by gmanucci » Wed Oct 21, 2015 2:17 pm

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: 7.5

Re: Calculation of Face Area

Unread post by nikhilruikar » Wed Oct 21, 2015 3:31 pm

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: 7.6
Location: The netherlands
Contact:

Re: Calculation of Face Area

Unread post by Mark Oostveen » Wed Oct 21, 2015 10:19 pm

Of course if you shape is a solid there are no boundaries. It is closed
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: 7.5

Re: Calculation of Face Area

Unread post by nikhilruikar » Mon Oct 26, 2015 7:38 am

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: 7.6
Location: The netherlands
Contact:

Re: Calculation of Face Area

Unread post by Mark Oostveen » Tue Oct 27, 2015 6:49 am

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