Hatch centroid definition

Hello, I wonder if is it possible to get the hatch’s centroid coordinates, without transforming into dynamo geometry.
That way works fine if the hatch has no hole by getting the patch surface from the policurve. However if the hatch has holes the geometry obteined has more than one policurve and you have multiple centroids.
My target is to write Mtext from hundred of hatches getting value from property set areas and positioning that text in the centroid.
Hatches with multiple holes has an area discounting holes.

Thanks in advance.

Hi @javiermend,

I think getting the true mathematical centroid will be a challenge. There is no method or property (that I know of) in the API that will do that. How about getting the center of the hatch’s bounding box?

Another thought is that you could skip the property sets and just get the area of the hatch directly using ObjectExtensions.GetParameterByName.

7 Likes

Hi @mzjensen ,
Can you give me the dynamo file for reference?
Thank you very much!

@lebinhx3c2012 - sorry, I created it as a really quick example and didn’t save it. You should be able to re-create it without too much trouble. All of the nodes are shown in the screen recording. The Select Object node is selecting the hatch object in model space.

1 Like

@mzjensen , No problems. Thank you!

Cool idea about using center of bounding box :+1:t2:

Hi @mzjensen .
You can remove zeros after the decimal point.
image
Thank You.

@lebinhx3c2012

Till mzjensen gets back, you can use String.Remove node for above task.

4 Likes

Thank you verry much.

thank you @mzjensen ! that works, i realise that i had an old version of civil3dtoolkit, and this node was missing.
other way…I try to filter by boolmask by using ObjectTypes node, however it get an error, Do you know why?
How i can filter out without using the selecting node?
It is a pity, that you can’t select Hatch by object Typs node.

There is a node in the Toolkit called DocumentExtensions.AddNewTypes. If you add that to the graph and then run it once, there will be additional types added to the Object Types drop down, including hatches.

FIY I just used this method to make Mtext labels for names of 65 catchments, since Civil 3D doesn’t have a way to add new labels to all catchments at once. Thanks again.
Catchment Names as Mtext.dyn (143.6 KB)

4 Likes