Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

hatch area lisp

aboqamar25
Explorer

hatch area lisp

aboqamar25
Explorer
Explorer

I have lisp to to label the hatch area for one hatch  at insertion point 

can anyone help me to modify the lisp to make it sum more than one hatch and label 
I will appreciate that  

0 Likes
Reply
Accepted solutions (1)
14,643 Views
11 Replies
Replies (11)

hak_vz
Advisor
Advisor

@aboqamar25 Attach lisp file and sample drawing

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes

hak_vz
Advisor
Advisor
Accepted solution

Here you have one simple solution.

 

(defun C:hatcharea () (hatcharea))
(defun hatcharea ( / ss area i eo pt) 
(setq
	ss (ssget '((0 . "hatch")))
	area 0
	i 0
)
(cond 
	((and(and ss) (> (sslength ss) 0))
		(repeat (sslength ss)
		(setq eo (vlax-ename->vla-object (ssname ss i)))
		(setq area (+ area (vlax-get eo 'Area)))
		(setq i (+ i 1))
		)
		(while (not pt)(setq pt (getpoint "\nSelect area text insertion point >")))
		(command "text" pt "" "" (strcat "Area = " (rtos area 2 2) " sq. units") "")
	)
)
(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

diagodose2009
Collaborator
Collaborator

You search BrokenHatch(s) before  calculate ARea.

Count BrokenHatch(s)=5=Which type/s of Hatch/s
?(B-broken.hatch)(A.all-okai):BDo you wish Loop (y-yes)(n-no)(n-nu)?:; error:
bad argument type: fixnump: (2.23223e+006 6.69861e+006 0.0)

 

0 Likes

aboqamar25
Explorer
Explorer
thank you for your time its what I need but how to define the height of the text 
 
0 Likes

aboqamar25
Explorer
Explorer

 thanks I found out 

0 Likes

hak_vz
Advisor
Advisor

You can change

 

(command "text" pt "" "" (strcat "Area = " (rtos area 2 2) " sq. units") "")

 

With let say

 

(command "text" pt 2.5 "" (strcat "Area = " (rtos area 2 2) " sq. units") "")

 

 

In first case text height is defined by system variable TEXTSIZE

 

Area string can be changed to comply to your request

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes

diagodose2009
Collaborator
Collaborator

I extract for you, the function dfn_enak_text from "pp_hatcharea_jsldc31.lsp" . You must extend the solution with the my.function .

(dfn_enamk_text hostpoint sizeh msgwap nil nil nil colorinteger "").

You must replace (command "text") with (dfn_enamk_text (getpoint) sizeh "msgwap" nil nil nil color ""). 

 

 

 

(defun dfn_enamk_text( g335 inal mesj alig rota laie culo stil / rr x y z h g el isla vela ldxf q y i z c1 c2 c3 c0 ck p h w rstr stas) 
   (setq;|a34240|;
	 rstr (read "STR")
	 stas "STANDARD"
	 c0 48
	 ck "*[0-9]*"
	 laie (if (=  laie nil) (getvar "CLAYER") laie)
	 alig (if (=  alig nil) "0MC" alig)
	 rota (if (=  rota nil) 100.0 rota)
	 inal (if (=  inal nil) (getvar "TEXTSIZE") inal)
	 culo (if (=  culo nil) 256 culo)
	 stil (if (=  stil nil) stas (if (and (=  (type stil) rstr) (>  stil "") (tblsearch "STYLE" stil)) stil stas))
	 isla (if (and (=  (type laie) rstr) (>  laie "") (tblsearch "LAYER" laie)) T nil)
	 laie (if (=  nil isla) "0" laie)
	 rota (if (=  (type rota) (read "REAL")) rota 0.0)
	 c1 (substr alig 1 1)
	 c2 (substr alig 2 1)
	 c3 (substr alig 3 1)
	 c1 (if (wcmatch c1 ck) (- (ascii c1) c0) 0)
	 c1 (if (>  c1 1) 1 (if (<  c1 0) 0 c1))) (setq;|a35026|;
	 c2 (if (wcmatch c2 ck) (- (ascii c2) c0) 0)
	 c2 (if (>  c2 3) 3 (if (<  c2 0) 0 c2))) (setq;|a35164|;
	 c3 (if (wcmatch c3 ck) (- (ascii c3) c0) 2)
	 laie (strcase laie)
	 x (car g335)
	 y (cadr g335)
	 z (caddr g335)
	 z (if (=  z nil) 0.0 z)
	 stil (if (and (=  (type stil) rstr) (>  stil "")) stil stas)) (setq;|a35416|;
	 ldxf (list (cons 0 "TEXT") (cons 1 mesj) (cons 7 stil) (cons 8 laie) (cons 10 g335) (cons 40 inal) (cons 50 rota) (cons 62 culo) (cons 71 c1) (cons 72 c2) (cons 100 "AcDbText") (cons 73 c3) (cons 11 g335))) (setq;|a35744|;
	 q nil) (setq;|a35760|;
	 g (entmakex ldxf)) 
g)

 

 

 

Can you find rotation-angle bug?

0 Likes

Sea-Haven
Mentor
Mentor

As you probably know two types of text style with a height set or set to 0.0 depending on which can affect the "TEXT" command, I normally set the correct style to make sure no error. More recently went for a entmake so ht becomes less dependant. Can remove lor and ver options for justification override.

 

(defun AH:text (pt hgt str ang lor ver )
 (entmakex (list (cons 0 "TEXT")
    (cons 10  pt)
    (cons 40 hgt)
    (cons 1  str)
	(cons 50 ang)
	(cons 71 0)
	(cons 72 lor)
	(cons 11 pt)
	(cons 73 ver)
	)))

 

 

0 Likes

tony1978
Collaborator
Collaborator

If you are interested, our company released an app that creates a dynamic table for all your hatches, providing quantity by SY or CY, or even cost. See our video links below. Its called Pavement Quantities. So when you add or remove hatches it will update the quantities for with an update button for the table. 

 

https://www.civilcadls.com/custom-apps

 Tony Carcamo


President/Owner


Civil CAD Learning Solutions


DFW BIM Infrastructure User Group


LinkedIn | Twitter | Instagram | DFWBIUG |User Group




0 Likes

lephuocthinh1993
Observer
Observer

How to replace (this area value) a text, please? Thanks!

0 Likes

ssaussy
Explorer
Explorer

When I run this routine, I get "Unknown command "HATCHAREA" after I select the insertion point, even though it displays the area information in my command history.

 

Command: HATCHAREA
Select objects: 1 found
Select objects:
Select area text insertion point >text
Current text style: "SX-FRAC" Text height: 0'-4 1/2" Annotative: No Justify: Left
Specify start point of text or [Justify/Style]:
Specify rotation angle of text <0>: 2.5
Enter text:
Command: Area = 11697.90 sq. units Unknown command "90 SQ. UNITS". Press F1 for help.
Command: HATCHAREA
Unknown command "HATCHAREA". Press F1 for help.

 

EDIT: So I removed one of the "" and it works now.

 

EDIT 2: Added (setq area (/ area 144)) to make the text display square feet instead of square inches when working in architectural. Leave strcat argument to (rtos area 2 0) though.