Author Topic: Select Similar Hatch for Gross Area  (Read 4460 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Select Similar Hatch for Gross Area
« on: June 20, 2017, 07:35:16 AM »
I was looking if there is a easy way to get the gross areas of these hatches if I select similar. I am not having any luck.

I know the long way of doing it with Re-associating a boundary with it on each one and then delete the hatch. . .

Is there a routine that I could select all of them and converts them over to a hatch that gives me the area with the same source hatch pattern? Just brainstorming around.

Thanks for any ideas.
Civil3D 2020

Rob...

  • King Gator
  • Posts: 3824
  • Take a little time to stop and smell the roses.
Re: Select Similar Hatch for Gross Area
« Reply #1 on: June 20, 2017, 08:03:46 AM »
That sounds like something Lee Mac would have.
CAD Tech

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Select Similar Hatch for Gross Area
« Reply #2 on: June 20, 2017, 09:14:07 AM »
I've been using THIS for years.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cadtag

  • Swamp Rat
  • Posts: 1152
Re: Select Similar Hatch for Gross Area
« Reply #3 on: June 20, 2017, 11:23:10 AM »
FILTER will let you select by Hatch Pattern Name.  Note that it is case-sensitive
The only thing more dangerous to the liberty of a free people than big government is big business

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Select Similar Hatch for Gross Area
« Reply #4 on: June 20, 2017, 12:18:49 PM »
This will place boundaries on a layer named the same as the pattern name. Then you can tally the areas by layer name.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:hbound (/ *error* i p s v x)
  2.   (defun *error* (msg)
  3.     (mapcar '(lambda (x) (setvar (car x) (cdr x))) v)
  4.     (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
  5.       (princ (strcat "\nError: " msg))
  6.     )
  7.     (princ)
  8.   )
  9.   (setq i 0)
  10.   ;; Tested in AutoCAD 2018 - RJP 6.20.2018
  11.   ;; Creates boundaries on layers that match the hatch pattern name
  12.   (if (setq s (ssget '((0 . "hatch"))))
  13.     (progn (setq
  14.              v (mapcar '(lambda (x) (cons x (getvar x))) '("clayer" "cmdecho" "hpseparate" "hpbound"))
  15.            )
  16.            (setvar 'cmdecho 0)
  17.            (setvar 'hpseparate 1)
  18.            (setvar 'hpbound 1)
  19.            (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
  20.              (if (null (tblobjname "layer" (setq p (cdr (assoc 2 (entget x))))))
  21.                (entmakex (list '(0 . "LAYER")
  22.                                '(100 . "AcDbSymbolTableRecord")
  23.                                '(100 . "AcDbLayerTableRecord")
  24.                                '(70 . 0)
  25.                                (cons 2 p)
  26.                                '(6 . "Continuous")
  27.                                (cons 62 (setq i (1+ i)))
  28.                          )
  29.                )
  30.              )
  31.              (setvar 'clayer p)
  32.              (command "_hatchgenerateboundary" x "")
  33.            )
  34.            (mapcar '(lambda (x) (setvar (car x) (cdr x))) v)
  35.     )
  36.   )
  37.   (princ)
  38. )
« Last Edit: June 21, 2017, 08:50:12 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Select Similar Hatch for Gross Area
« Reply #5 on: June 21, 2017, 07:56:05 AM »
Hey Thanks for taking a stab at this. I have great news for you. I think you solved my problem! (as usual) :) With using this routine in 2017, I don't seem to get the same outcome as you do in your animated photo. Mine simply shows a red triangle in the left side of the screen. weird.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Select Similar Hatch for Gross Area
« Reply #6 on: June 21, 2017, 08:51:19 AM »
Strange ... it worked for me in '17 & '18 :?  Give it a try again .. changed a couple more variables.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Select Similar Hatch for Gross Area
« Reply #7 on: June 21, 2017, 09:23:34 AM »
more weird.... Still getting the same thing. Let me reset my CAD. Maybe there is something on my end.

I saved it and then audit'ed it.

Code: [Select]
Command: _QSAVE Drawing saved in AutoCAD 2013 format.
Command: auidt Unknown command "AUIDT".  Press F1 for help.
Command: *Cancel*
Command: *Cancel*
Command: audit
Fix any errors detected? [Yes/No] <N>: y
Auditing Header
Auditing Tables
Auditing Entities Pass 1
Pass 1 400     objects auditedAECC_ALIGNMENT_STYLE (AcDbSymbolTableRecord)
                    eNullObjectId                       Standard
AECC_ALIGNMENT_STYLE (AcDbSymbolTableRecord)
                    eNullObjectId                       Standard
AECC_ALIGNMENT_STYLE (AcDbSymbolTableRecord)
                    eNullObjectId                       Standard
AECC_ALIGNMENT_STYLE (AcDbSymbolTableRecord)
                    eNullObjectId                       Standard
Pass 1 3400    objects audited
Auditing Entities Pass 2
Pass 2 3400    objects audited
Auditing Blocks
 1       Blocks audited
Auditing AcDsRecords
Total errors found 4 fixed 4
Erased 0 objects
Command:
Command: (LOAD "C:/Users/rberger/Desktop/tmp.lsp") C:HBOUND
Command: hbound
Select objects: Specify opposite corner: 18 found
Select objects:
*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group/Add/Remove/Multiple/Previous/Undo/AUto/SIngle
Select hatch objects: *Cancel*
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Select Similar Hatch for Gross Area
« Reply #8 on: June 21, 2017, 09:36:41 AM »
That's odd .. it's like the hatch you're trying to select is not being recognized. ( *Invalid selection* )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Select Similar Hatch for Gross Area
« Reply #9 on: June 21, 2017, 09:43:39 AM »
Wow... I just reset everything (Even the registry and Appdata). Downloaded your drawing.  Bummers.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Select Similar Hatch for Gross Area
« Reply #10 on: June 21, 2017, 10:14:31 AM »
Wow... I just reset everything (Even the registry and Appdata). Downloaded your drawing.  Bummers.
Gotta be some variable .. this is why I rarely use command calls.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Select Similar Hatch for Gross Area
« Reply #11 on: June 21, 2017, 10:44:32 AM »
Hey I appreciate the help! You did a great job! I think my CAD doesn't like me. lol
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Select Similar Hatch for Gross Area
« Reply #12 on: June 21, 2017, 10:54:56 AM »
I did stumble on this code

Code: [Select]
(DEFUN C:RB () (setvar "osmode" 0) (setq ss1 (ssget '((0 . "HATCH")))) (setq len1 (sslength ss1) n1 0) (while (< n1 len1) (setq

ename1 (ssname ss1 n1)) (COMMAND "HATCHEDIT" ename1 "B" "" "Y") (setq n1 (1+ n1)) ) ) ;end RB

Could this possibly replace the _HATCHGENERATEBOUNDARY command?

I think that might be my problem.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Select Similar Hatch for Gross Area
« Reply #13 on: June 21, 2017, 11:06:59 AM »
I did stumble on this code

Code: [Select]
(DEFUN C:RB () (setvar "osmode" 0) (setq ss1 (ssget '((0 . "HATCH")))) (setq len1 (sslength ss1) n1 0) (while (< n1 len1) (setq

ename1 (ssname ss1 n1)) (COMMAND "HATCHEDIT" ename1 "B" "" "Y") (setq n1 (1+ n1)) ) ) ;end RB

Could this possibly replace the _HATCHGENERATEBOUNDARY command?

I think that might be my problem.
You could try: (command "-hatchedit" x "Boundary" "Polyline" "Yes")
in place of: (command "_hatchgenerateboundary" x "")

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Select Similar Hatch for Gross Area
« Reply #14 on: June 21, 2017, 12:29:24 PM »
Sun of a gun. That worked. I wonder why it was so picky. Strange. Its a thing of beauty :) Btw howd you make your pretty table lol. Very colorful.
Civil3D 2020