Can I ask you some calculation questions?

Can I ask you some calculation questions?

raymondcheng0922
Enthusiast Enthusiast
304 Views
2 Replies
Message 1 of 3

Can I ask you some calculation questions?

raymondcheng0922
Enthusiast
Enthusiast

Can the area answer be between 2 and 10? If less than 2, mark it as 2. If it is greater than 10, mark it as 10.

 

 

 

(defun c:2_sset_area (/ _nomutt _prompt list_1 list_2 )
(setq _nomutt (setvar 'nomutt 0) _prompt (prompt "\nSelection set 1: ") _nomutt (setvar 'nomutt 1)
list_1 (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "lwpolyline") (-4 . "&=") (70 . 1)))))))
_nomutt (setvar 'nomutt 0) _prompt (prompt "\nSelection set 2: ") _nomutt (setvar 'nomutt 1)
list_2 (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "lwpolyline") (-4 . "&=") (70 . 1)))))))
_nomutt (setvar 'nomutt 0)
)
(vla-addmtext (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-3d-point (getpoint "\nPick point for placing calculated mtext: "))
0
(strcat
(strcat "%<\\AcExpr ("
(apply 'strcat (cdr (apply 'append (mapcar '(lambda (pline) (list "+" (strcat "%<\\acobjprop.16.2 object(%<\\_objid " (itoa (vla-get-objectid pline)) ">%).area>%"))) list_1))))
(apply 'strcat (apply 'append (mapcar '(lambda (pline) (list "-" (strcat "%<\\acobjprop.16.2 object(%<\\_objid " (itoa (vla-get-objectid pline)) ">%).area>%" ))) list_2)))
") \\f \"%lu2\">%"
)
)
)
(princ)
)

0 Likes
Accepted solutions (2)
305 Views
2 Replies
Replies (2)
Message 2 of 3

komondormrex
Mentor
Mentor
Accepted solution

you mean no fields if result < 2 or result > 10?

like that?

(defun c:2_sset_area (/ _nomutt _prompt list_1 list_2 )
	(setq _nomutt (setvar 'nomutt 0) _prompt (prompt "\nSelection set 1: ") _nomutt (setvar 'nomutt 1)
		   list_1 (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "lwpolyline") (-4 . "&=") (70 . 1)))))))
		  _nomutt (setvar 'nomutt 0) _prompt (prompt "\nSelection set 2: ") _nomutt (setvar 'nomutt 1)
		   list_2 (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "lwpolyline") (-4 . "&=") (70 . 1)))))))
		  _nomutt (setvar 'nomutt 0)
		  result (- (apply '+ (mapcar 'vla-get-area list_1)) (apply '+ (mapcar 'vla-get-area list_2))) 
	)
	(vla-addmtext (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
		(vlax-3d-point (getpoint "\nPick point for placing calculated mtext: "))
		0
		(cond
			(
				(> 2 result)
					"2"
			)
			(
				(< 10 result)
					"10"
			)
			(strcat
				(strcat "%<\\AcExpr ("
					(apply 'strcat (cdr (apply 'append (mapcar '(lambda (pline) (list "+" (strcat "%<\\acobjprop.16.2 object(%<\\_objid " (itoa (vla-get-objectid pline)) ">%).area>%"))) list_1))))
					(apply 'strcat (apply 'append (mapcar '(lambda (pline) (list "-" (strcat "%<\\acobjprop.16.2 object(%<\\_objid " (itoa (vla-get-objectid pline)) ">%).area>%" ))) list_2)))
					") \\f \"%lu2\">%"
				)
			)
		)
	)
	(princ)
)
0 Likes
Message 3 of 3

raymondcheng0922
Enthusiast
Enthusiast
Accepted solution

Thank you 

but Variables will be invalid

field has no original function.

0 Likes