Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

A lisp file that can read the total area of each hatch and ....

74 REPLIES 74
SOLVED
Reply
Message 1 of 75
JamaL9722060
19432 Views, 74 Replies

A lisp file that can read the total area of each hatch and ....

A lisp file that can read the total area of each hatch and summarize them in a table,

 

Assume that I have multiple hatches of different patterns and color (attached) and I wanted to calculate their areas (and summarize them in a table along with a symbol represents their color) based on their color such that the areas of hatches of same color are accumulated.

 

This can be done partially using the command “extract data” but has two issues:

 

  • It has no ability to stick a symbol for the color on the table (instead of listing their numbers)
  • It has no ability to accumulate the areas in case they have similar color

 

 

Thank you

 

Best

 

Jamal

---------------------------
Jamal Numan
74 REPLIES 74
Message 61 of 75
devitg
in reply to: JamaL9722060

@Anonymous , ok but the first column will not have the  Hatch , as in the previous DWG 

 

Jamal Hatch Area2-in current units.dwg 

 

devitg_1-1625494911776.png

 

 

in the new dwg 3DS-B62--w description.dwg

 

devitg_0-1625494859981.png

will nit show teh hatch pattern 

 

Message 62 of 75
devitg
in reply to: devitg

@Anonymous 

About TEXT inside the hatch , it seem to be the same as the hatch layer name . Or it be some diferents text .

Message 63 of 75
devitg
in reply to: Anonymous

@Anonymous , as to be able to get the text it shall be inside a  closed polyline enclosing the hatch . 

This way the text can be selected by CP or WP  ssget . 

Other way , and as far I know, I can not select the text inside each hatch . 

see dwg attached 

Message 64 of 75
devitg
in reply to: Anonymous

@Anonymous  hi terin , some like it ?

 

devitg_0-1625707978093.png

 

Message 65 of 75
Sea-Haven
in reply to: devitg

Removed solution ok for polygons not arcs. need to use HATCHGENERATEBOUNDARY but then convert arcs to a series of shorter segments then can use ssget "WP" pts & TEXT using the co-ordinates of the pline. Now where is convert pline arc to pline with multi arcs.

 

 

 

; get objects using hatch
; By AlanH june 2021
removed not quite right

 

 

 

 

 

Message 66 of 75
Anonymous
in reply to: devitg

Dear @devitg 

 

Yes this table in your drawing that I mean. So I want to ask solution by lisp?

Thank so much!

12.png

Message 67 of 75
Anonymous
in reply to: JamaL9722060

Hello, anyone helps me to edit this code to area /1000000  and add m2 at end? Thanks!

 

 

 

(defun c:tmp (/ area sset P1)
      	(vl-load-com)
      (cond ((and
	      	(ssget ":L" '((0 . "Hatch")))
	      	(setq area 0)
	     	(vlax-for H (setq sset (vla-get-activeselectionset
	                                     (vla-get-activedocument
	                                           (vlax-get-acad-object))))
	              (setq area (+ (vla-get-area h) area))
	              )


              (setq P1 (getpoint "\nPick text point: "))

        (entmake
          (list
            (cons 0 "TEXT")
            (cons 40 18.0)               
            (cons 10 P1)
            (cons 1 (strcat
		            "\nTotal Area = "
		            (if (or (= (getvar "lunits") 3)
		                    (= (getvar "lunits") 4))
		                  (strcat
		                        (rtos area 2 2)
		                        " sq. in. ("
		                        (rtos (/ area 144) 2 2)
		                        " sq. ft.)")
		                  (rtos area))))
          );list
        );entmakex
                (vla-delete sset)
                ))
            )
      	)

 

 

Message 68 of 75
Anonymous
in reply to: JamaL9722060

Hello I need a help, can anyone help me to edit it? thanks!

Message 69 of 75
devitg
in reply to: JamaL9722060

 @Anonymous , will you apply this lisp to this dwg?

 

 

devitg_0-1626190457004.png

 

If so , the lisp will not work , because your lunits is set to 2, for decimal and up to 4 places decimal part. and your insert units is inches 

devitg_1-1626190612154.png

 

 

 

 

, and lunits 3 and 4 are for 

as follow

LUNITS Value
Description
1 Scientific
2 Decimal
3 Engineering
4 Architectural
5 Fractional.

 

Please clear it 

 

 

 

 

 

 

Message 70 of 75
Anonymous
in reply to: devitg

Dear @devitg 

I dont know,

123.jpg

but lisp is also working in this case?

Message 71 of 75
devitg
in reply to: JamaL9722060

 yes it can work , , but suited to the DWG 

 

Message 72 of 75
Anonymous
in reply to: JamaL9722060

Thank you @devitg 

We can modify by add /1000000 to this line:

(rtos (/ area 1000000))
Message 73 of 75

Why I can't see hatch area pattern? What's wrong with me?

Message 74 of 75

I CAN NOT SEA HATCH PREVIEW

Message 75 of 75

I CAN NOT SEA HATCH COLORS IN AREA TABLE

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report