# Shape perimeter

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

Accepted Solutions
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
7 Replies
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
New Contributor II
Im not talking about area. Im trying to find shepe perimeter/circumference, sum of the length of all edges.
Frequent Contributor
Ah.

that's currently not directly queryable with a function.

I recommend :

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

ok ?

m.
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?
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
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
New Contributor II
Wow, great. Didnt see that coming. Realy nice trick with the area. Thanks