Select hatchs with dynamo

Hello, I hope you can help me with this problem. I am trying to make a selection of all the layers in my document and have Dynamo give me the total areas per layer, but I am having problems with this. If you can help me, I would really appreciate it.

1 Like

Add a List.RemoveIfNot after the all objects on layer.

Alternatively you CPU’s get the object type from the resulting objects and use an equality test to check for equality to the name of hatch object. The resulting boolean becomes a filter for the object lists - make sure both inputs on the List.FilterByBoolMask node are set to @@L2 to keep things aligned.

Alternatively you could select all hatches first and then group their by their layer.

Hi Jacob thanks for your answer, I’ve questions for the solution what you bring me. When I try to make the list.remove if not, in the type i don’t know what type i need to make the seleccition, i supposee is the hatch but, I’m really lost with this.

Hi,
Have you verified your hatch? I see that Loop = 0.
I think you don’t need to filter your objects; I didn’t encounter any issues.

Can you post what you’ve tried? Hard to guide you out of the woods if you don’t indicate where you are.

Hi, i try another form to get the areas, but in my draw how i´ve 56 layers, including multiple polylines, i nedd to create a filter for only count the hatches right?, bucause, when i try to make a list, tha full area does not appear

Not sure what direction you’re going now…

Currently half your problem is that you’re trying to learn how to swim during a sharknado of data, and that never ends well. So instead of jumping into N layers with M objects per layer of which L are hatches start simple.

Make a new dwg with 4 layers named ["0", "1", "2", "DefPoints"] (or whatever the standard no-plot layer in AutoCAD is). Put 2 hatch objects on layer “0”. On layer “1” put a hatch and a line. On layer “2” put two lines. On the defpoints layer put nothing.

When you use All Objects On Layer you should have a total of 6 objects. Then try Hatch.GetFromObject and Hatch.Area and see if the structure makes more sense.

Ok, I do it.

Now, in the actualy dwg I´ve 2 polylines and 2 hatchs, and four layers only.

In the Hatch.getfromobjetc, I get the hatch and next the area, but how i filter the hatch; ‘Solid fill’ in the list 0, and 2, so that null does not appear and only hatch

And really thanks for your help.

Put a List.Clean in after the “Hatch.GetFromObject” node to remove the ‘null’ objects.

Excellent, and sorry but one more question, since before the number was null, it gave numbers of 0 when applying the function to add the elements by list, so it did not order the list of layers, how do I adapt a list with the names of the layers and the shaded area?

There should be one sum of the hatch areas for each layer, with empty lists totally 0 area. You might need two ‘sum’ nodes or a List.Flatten with the correctly list Level (@L3 I think) to ensure things maintain alignment. Using the sample file and double checking your results will help ensure things align for now.

Hi again, thanks for your answer. I’ll try to apply this answer and your first answer to my post because I don’t know how I can make a filter and dynamo bring me the layer name exactly with the area like the number 0, 1, 2. My last picture is the layer 4, 15 and 17 with their respective names. I don’t know how to make a layer: List 4 (CA-EJE) = list 0 (8.293) Hatch Area

On the List.Clean node set the ‘preserve indicies’ to ‘True’ and see if that clears it up. :slight_smile:

Hi, again thanks for your help, I’m really apreciate that, yes with this, the list.clean, preserve indices, but in the final list, i have problems with the sum, but the simple solutyion in the dwg is drag with a lot of layer only to hatches and not the same for polyline and hatch.

Hey Ramon,

Take a look at this solution and see if it works for your needs. Should filter out all the non-hatch items on your layers, sum up the hatches and sort them into a dictionary by layer name and total area.

Update!

These days I have been working on the Script, with all your comments, the answer I found is the following:

When I try to classify the lines by layers all the lines are with distance at 0, and the hatches with different areas are all fine in the list, the problem, if this same layer has been used in a polyline and hatching the Script to give distances or hatching area is null, and the list does not work.

And for that the solution is very simple, create multiple layers for my drawing, layers to draw polylines and layers for hatching, with this if my drawing has polylines and hatching, I have no problem, because with the different layers, to give the hatching area or the distances it works fine.

The only problem is the accumulation of layers, for a large drawing it can be complicated but if I work very specifically with my layers, I can know areas and distances automatically.

Thanks again for all your help, for the moment I will work with many layers haha.