Shape perimeter

904
7
Jump to solution
10-07-2013 05:36 AM
AleksandarLalovic
New Contributor II
Is there a way to calculate shepe/block perimeter?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MatthiasBuehler1
Frequent Contributor
after thinking for a minute, you could do something like this :


@Hidden attr perimeter = 0  Lot -->     extrude(1)     set (perimeter, geometry.area() - 2 * (geometry.area(bottom))     comp(f) { bottom : reverseNormals Gotcha. }


the idea of course being that you take the full surface after the extrusion, subtracting the bottom and top area, then dividing again by the extrusion height.


cheers !

matt

View solution in original post

0 Kudos
7 Replies
MatthiasBuehler1
Frequent Contributor
Hi,

In CGA, you can use geometry.area() to find a shape's area.

Check the docs on how to precisely use it.

If you report the area and select all shapes, the Reports tab in the Inspector will show the sum of all areas.

But since CGA operates only on single shapes, CGA has no way to 'collect' reported data of it's neighbor shapes in the same Block.

Python scripting may give you a few workflow options though.

Ok ?

matt
0 Kudos
AleksandarLalovic
New Contributor II
Im not talking about area. Im trying to find shepe perimeter/circumference, sum of the length of all edges.
0 Kudos
MatthiasBuehler1
Frequent Contributor
Ah.

that's currently not directly queryable with a function.

I recommend :

comp(e) { all : report("edgeLength", scope.sx) NIL }

ok ?

m.
0 Kudos
AleksandarLalovic
New Contributor II
For the reporting this works just fine but if i would like to use this value in a rule file i guess its not possible?
0 Kudos
MatthiasBuehler1
Frequent Contributor
Hi,

there's one more, much more complex way to obtain directly in CGA.

otherwise, I'd recommend to use Python to quickly take the reports and write them as an object attribute.

let me know if you're interested in the complex way. I'll need to adapt an other existing rule for this, will take a bit of time.


matt
0 Kudos
MatthiasBuehler1
Frequent Contributor
after thinking for a minute, you could do something like this :


@Hidden attr perimeter = 0  Lot -->     extrude(1)     set (perimeter, geometry.area() - 2 * (geometry.area(bottom))     comp(f) { bottom : reverseNormals Gotcha. }


the idea of course being that you take the full surface after the extrusion, subtracting the bottom and top area, then dividing again by the extrusion height.


cheers !

matt
0 Kudos
AleksandarLalovic
New Contributor II
Wow, great. Didnt see that coming. Realy nice trick with the area. Thanks
0 Kudos