Hi all,
I created a hatch and I'd to know if there is how to count how many square has inside of the perimeter.
Maybe a lisp can help me doing that.
Regards
Solved! Go to Solution.
Solved by gpcattaneo. Go to Solution.
Instead of using hatch, you can create a polyline square then array it to fill an area larger then the boundary. Explode the array object.
Then use attached SMARTSEL.vlx with WP option to select all square inside. It will report how many squares selected.
You can select multiple polylines/circles as boundaries.
Command: smartsel
Selecting mode [Wp/Cp] <Cp>:wp
Find all circles/Polylines on same layer as selecting boundary? [Yes/No] <Y>:n
Pick a circle/polyline:
Pick a circle/polyline:
Checking entities: 1 of 1
xxx entities are selected.
Maybe this topic can help...
@gp
Thank you very much for the code. It's just amazing, you helped me a lot.
I'd like to insert a text with the total of polylines. Could you help me out, please?
Regards
@F.Camargo wrote:
....
I created a hatch and I'd to know if there is how to count how many square has inside of the perimeter.
....
Will the perimeter always be a rectangle, and will the Hatch pattern always have an origin point at one corner, as in the sample drawing? If so, since that's a User-defined Hatch, it would be pretty simple to calculate the number of complete squares from the rectangle's size and the Hatch pattern's Spacing. Even if it wouldn't always have an origin at a corner, I think it would be only a little more complicated to make compensation for that.
You've gotten some pretty good help. If your real goal is estimating, get the area of the boundary and divide by the area of a single hatch square. If you goal is counting how many parts, then others have already posted great solutions.
When you use SMARTSEL, with WP option, the number of block/square polyline you selected are full squares. Then use CP option to select again. The different between CP and WP is the "half" square number (less than a full square).
@F.Camargo wrote:
Thank you very much gp.......................
I don't want to take advantage of your willingness. would you mind to improve the code to count half squares too?
e.g
26 squares created
35 half squares
You're welcome.
Try this:
Hi gp,
The code isn't count the halves squares.
I attached the file example.
Thank in advance
@gpcattaneo wrote:
@F.Camargo wrote:The code isn't count the halves squares.
Your boundary is a polyline.
yes, I make boundary in red to represent halves squares.
I'd like to know if is possible to count that halves squares too.
Perfect gp!
Thank you very much for the help.
I'm really satisfied with the goal. 🙂
Some images for better understanding how to use SMARTSEL to do the counting task:
Step 1, Create array of square blocks or polylines to cover an area bigger than the boundary line. Then explode the array object.
Step 2, Use SMARTSEL, WP option to select all whole blocks inside the boundary. It shows how many entities are selected in the command line.
This number (176 in the example) is the whole square number.
Graphic result:
Step 3, Use SMARTSEL again, CP option to select all blocks inside the boundary and on the boundary. It shows how many entities are selected in the command line.
Graphic result:
Step 4, Use the result in Step 3 minus the result in Step 2 to get the number of "half" squares. In the example, it is 247-176=71