How extract area and an arc length from a region construct by a sketch

How extract area and an arc length from a region construct by a sketch

moraesorlando
Advocate Advocate
903 Views
6 Replies
Message 1 of 7

How extract area and an arc length from a region construct by a sketch

moraesorlando
Advocate
Advocate

Hello colleagues!

 

I am here again to ask for help.

 

I have already got good answers about how extract values from solid bodies and put these values in fields within a form from this forum and I am grateful for that.

 

Now I have a similar situation but the values to be extract does not come from a solid but from a region created in a sketch.

 

Below are the steps about how I wonder this is going to work:

 

After load the form.

 

The user clicks in a button and select an arc from a region created by sketch. The value of the arc length is shown in the respective field in the form.

 

Then The user clicks in a second button and select an internal area from any region existent in the sketch and the value of internal area is shown in the respective field in the form.

 

I have prepared the form, the parameters, the buttons but I don’t know how to create the ilogic code.

And I would like to count with the colleagues to help to accomplish this target.

 

I have prepared an image to help to transmit my idea.

 

I am also attaching the file with all the preparations to receive the code.

 

I am using Inventor version 2020 and I am available to supply any other necessary information.

 

Thanks in advance for every one that can help.

 

Best regards,

 

0 Likes
Accepted solutions (1)
904 Views
6 Replies
Replies (6)
Message 2 of 7

JhoelForshav
Mentor
Mentor

@moraesorlando 

I've filled in the rules in your attached ipt 🙂

I hope it's what you are looking for.

 

See attached ipt.

Message 3 of 7

moraesorlando
Advocate
Advocate

Hello @JhoelForshav 

 

Congratulations! You always are solving the cases, thank you very much!

 

I have placed these rules in my real situation and works correctly!

 

That’s exactly what I am looking for.

 

Just an additional question.

 

How can I do to control the number of decimal places of in area and length results?

 

For example, in the region identified with “Internal area”:

 

Is possible to get the number 2002.xxxxxxxxxxx for area result.

 

How to control the decimal places to get 2002.243 or 2002,24282?

 

Thanks in advance.

 

Best regards,

0 Likes
Message 4 of 7

JhoelForshav
Mentor
Mentor

Hi @moraesorlando 

See attached ipt. I've added a parameter to the part where you can set the number of decimal places you want to use and updated the code accordingly 🙂

 

Message 5 of 7

moraesorlando
Advocate
Advocate

 

Hello @JhoelForshav after a long time I got back to this pursuit

 

I was engaged in other Inventor pursuits (sorry about this long time to get back to finish this post).

 

I have tried to use the example in the file you sent to set the quantity of decimal places, but after a while trying to solve without succeeded I have identified the reason.

 

In your example to extract the value from area, you have used a parameter from type TEXT and in my real situation I have used a parameter FROM TYPE “Numeric”.

 

I think, because of this I could not set the decimal places adapting your code to my case.

 

The adapted code I am trying to use is:

 

 

Parameter.Param("High_Profile_Area").Value = Math.Round((oProfile.RegionProperties.Area * 10), 5, MidpointRounding.AwayFromZero)

 

 

Using numbers for better understanding:

The result of this code in my test is 98277,17290000

The results show 8 decimals places instead of 5

 

The expected value is 98277,17290

 

I believe the code I have adapted to set the decimal places shown above is not correct to a parameter type "numeric".

 

I appreciate your help.

 

Thanks in advance and best regards,

0 Likes
Message 6 of 7

JhoelForshav
Mentor
Mentor
Accepted solution

You should use .Expression instead of .Value then @moraesorlando 

 

I have two options for you. Both should work... See which one you like best.

 

You could do it like this:

Parameter.Param("Area_from_sketch").Expression = Math.Round((oProfile.RegionProperties.Area * 10), 5, MidpointRounding.AwayFromZero).ToString

Or like this:

Parameter.Param("Area_from_sketch").Expression = (oProfile.RegionProperties.Area * 10).ToString("0.00000")

 

Message 7 of 7

moraesorlando
Advocate
Advocate

Hello @JhoelForshav !

 

Thanks for your quick reply.

 

I have used the first example and everything worked as expected.

 

Thank you very much, you are very good on that.

 

One more case solved!

 

I will mark this post as accepted solution.

 

See you in the next Inventor pursuits.

 

Best regards,

0 Likes