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

hatch area lisp

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
aboqamar25
12896 Views, 10 Replies

hatch area lisp

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  

10 REPLIES 10
Message 2 of 11
hak_vz
in reply to: aboqamar25

@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.
Message 3 of 11
hak_vz
in reply to: aboqamar25

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.
Message 4 of 11
diagodose2009
in reply to: hak_vz

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)

 

Message 5 of 11
aboqamar25
in reply to: hak_vz

thank you for your time its what I need but how to define the height of the text 
 
Message 6 of 11
aboqamar25
in reply to: aboqamar25

 thanks I found out 

Message 7 of 11
hak_vz
in reply to: aboqamar25

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.
Message 8 of 11
diagodose2009
in reply to: aboqamar25

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?

Message 9 of 11
Sea-Haven
in reply to: hak_vz

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)
	)))

 

 

Message 10 of 11
tony1978
in reply to: aboqamar25

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




Message 11 of 11
lephuocthinh1993
in reply to: hak_vz

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

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