suriwaits 发表于 2022-7-6 06:38:50

Area of Polyline & Multiply by

Hi,
 
I am in need of a lisp to do the following
 
Find the individual area of poly line in layer 1 & Layer 2
Multiply the area in layer 1 by a factor 3.1 and Place text within polyline
Multiply the area in layer 2 by factor 4.1 and Place text within polyline
Sum of text as alert message
 
Please help me on this..
 
 
Thanks in Advance
 
Suriwaits

pBe 发表于 2022-7-6 06:53:15

(defun c:areafrom(/ data TotalArea ss i en area lay) (setq data '(("LAYER1" 3.1) ("LAYER2" 4.1)));;vla-object en) 'mn 'mx)      (setq pt               (mapcar '(lambda (x y)                       (* 0.5 (+ x y)))                        (vlax-safearray->list mn)               (vlax-safearray->list mx)))                      (entmakex (list (cons 0 "TEXT")                        (cons 10 pt)(cons 8 lay)                        (cons 11 pt)                        (cons 40 TextHt)                        '(72 . 1) '(73 . 2)                         (cons 1 (rtos (setq area (* (cadr (assoc lay data)) area)) 2 2))                  )      )      (setq TotalArea (cons area TotalArea))      )      (alert (Strcat "Total area:   " (rtos (apply '+ TotalArea) 2 2)))    ) ) (princ))
 
Code updated

suriwaits 发表于 2022-7-6 07:00:48

Exactly what i am looking for.
I appreciate you can help me to control the size of text

pBe 发表于 2022-7-6 07:10:59

We can add a prompt for Text Height. Which one did you use? Demo or Demo2?

suriwaits 发表于 2022-7-6 07:16:26

I used Demo2.
Is it possible to write the area value divided by 1000000 incase i use in mm units.

pBe 发表于 2022-7-6 07:28:10

 
See update code at post # 2
 
HTH

suriwaits 发表于 2022-7-6 07:34:43

Awesome!
 
Thanks agian pBe for your efforts
 
I have changed factor for mm 0.000001 insted of 0.001 since it is area.

pBe 发表于 2022-7-6 07:44:31

 
Oh yeah.. silly me.. Glad i could help
页: [1]
查看完整版本: Area of Polyline & Multiply by