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

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Water Moccasin
  • Posts: 2008
  • 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.
Autodesk Infrastructure Design Suite 2017

Rob...

  • King Gator
  • Posts: 3757
  • 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: 6312
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 10 x64 - AutoCAD /C3D 2018

Custom Build PC

cadtag

  • Swamp Rat
  • Posts: 1047
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: 6312
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 10 x64 - AutoCAD /C3D 2018

Custom Build PC

MSTG007

  • Water Moccasin
  • Posts: 2008
  • 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.
Autodesk Infrastructure Design Suite 2017

ronjonp

  • Needs a day job
  • Posts: 6312
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 10 x64 - AutoCAD /C3D 2018

Custom Build PC

MSTG007

  • Water Moccasin
  • Posts: 2008
  • 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*
Autodesk Infrastructure Design Suite 2017

ronjonp

  • Needs a day job
  • Posts: 6312
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 10 x64 - AutoCAD /C3D 2018

Custom Build PC

MSTG007

  • Water Moccasin
  • Posts: 2008
  • 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.
Autodesk Infrastructure Design Suite 2017

ronjonp

  • Needs a day job
  • Posts: 6312
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 10 x64 - AutoCAD /C3D 2018

Custom Build PC

MSTG007

  • Water Moccasin
  • Posts: 2008
  • 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
Autodesk Infrastructure Design Suite 2017

MSTG007

  • Water Moccasin
  • Posts: 2008
  • 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.
Autodesk Infrastructure Design Suite 2017

ronjonp

  • Needs a day job
  • Posts: 6312
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 10 x64 - AutoCAD /C3D 2018

Custom Build PC

MSTG007

  • Water Moccasin
  • Posts: 2008
  • 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.
Autodesk Infrastructure Design Suite 2017