Row Classification Script

Row Classification Script

carl3ZPF6
Enthusiast Enthusiast
2,198 Views
23 Replies
Message 1 of 24

Row Classification Script

carl3ZPF6
Enthusiast
Enthusiast

It has been a while since I have written code (I am a mechanical engineer) but I think this is a simple problem. At my job we put things in various rows and we need to be able to quickly classify rows. Let me explain: we will get an autocad file shown rectangles in rows like the following. Note when I am talking about rows I am talking about the up and down rectangles (Opposite of row/ column in spreadsheet sense).

carl3ZPF6_0-1685650772858.png

 

I need to color code and count rows of the following distinct categories:

  • Long Length Exterior rows (Rows that have less than 3 rows to the right and/or left of them )
  • Long Length Interior rows( rows that have other rows 3+ to the left and 3+ to the right)
  • Long length Overhang rows (rows that have short length rows in front of them, similar to exterior row rules 3 rows from the left or right will be considered an overhang row)
  • Short length exterior rows (same rules as exterior/ interior for long length rows)
  • Short length interior rows (same rules as exterior/ interior for long length rows)

Currently we manually color code them into different layers then we can use autocad to count the rectangles in each different categories see color coding below:

 

carl3ZPF6_1-1685650772864.png

 

Blue= Long Row Exterior Magenta= Long Row Overhang Red= Long Length Interior Green= short length interior Cyan= short length exterior.

This is easy enough for small files but these get very large and tedious for large sites, and to further complicated things, sometimes there are 3 length categories (short, medium, and long). Looking for an easy way to automate this process, I dabble in C++ and VBA and I feel like this should be rather simple, I just don't know where to start. this does not need to be done withing Auto cad and I can export the files as images or whatever is necessary.

 

0 Likes
2,199 Views
23 Replies
Replies (23)
Message 21 of 24

carl3ZPF6
Enthusiast
Enthusiast

Also upon further investigation angled rows also work fine i just did not have enough rows

carl3ZPF6_0-1685906853696.png

 

0 Likes
Message 22 of 24

Sea-Haven
Mentor
Mentor

The answer is in this "(GetPropertyValue (ssname polylines cnt) "Length") ; get the length".

 

Rather get the length of the longest side, this will ignore the implied width. Need to compare vertices v1-v2 & v2-v3. Greater distance is length to be used.

0 Likes
Message 23 of 24

Michiel.Valcke
Advisor
Advisor

@Sea-Haven I looked at that possibility with the dataset carl provided, his polylines have the same length/width but still get treated as if they have a different length. the only difference I could find was that they had a different elevation. But sometimes other polylines with different elevations did not cause a wrong classification, and if I create them myself and give them different elevations it also did not cause a misclassificaton.


0 Likes
Message 24 of 24

carl3ZPF6
Enthusiast
Enthusiast

I do believe the problem is in width variation that is making the lengths different for the same size rows, if I make a series of rows with one row that is slightly thinner I get similar issues. I think a simple fix here is to add some tolerance in each of the comparison functions. See attached code, this is my best attempt at that but it doesn't work. I changed the comparison to look at the absolute values of the differences and compare that to a percentage of the total length (8% in this case) for both the main function and the checklengths_MHV function. Any help would be appreciated.

0 Likes