Jump to content

Recommended Posts

Posted (edited)

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

Edited by suriwaits
Posted (edited)

(defun c:areafrom  (/ data TotalArea ss i en area lay)
 (setq data '(("LAYER1" 3.1) ("LAYER2" 4.1)));;<-- change this to.... [of course you know that]
 [b][color="blue"](and  (null unit)				;<-- will only ask you once
   	(not (initget "M MM"))                  
   	(setq unit (cadr (assoc (getkword  "\nChoos units to use [M/MM]: ") '(("M" 1.0)("MM" 0.000001))))))

  	
 (setq TextHt (cond
((getreal (strcat "\nEnter Text Height"
                (if TextHt (strcat " <" (rtos TextHt) ">: ") ": ")
                           )))(TextHt))
               )[/color][/b]
 (if
   (and
     (setq TotalArea nil
           ss        (ssget '((0 . "LWPOLYLINE") (8 . "LAYER1,LAYER2")))
     )
   )
    (progn
      (repeat (setq i (sslength ss))
        (setq en   (ssname ss (setq i (1- i)))
              area [b][color="blue"](* (vlax-curve-getarea en) unit)[/color][/b]
              Lay  (Strcase (cdr (assoc 8 (entget en))))
        )
        (vla-getboundingbox (vlax-ename->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)
                        [b][color="blue"](cons 40 TextHt)
                        '(72 . 1) '(73 . 2) [/color][/b]
                        (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

Edited by pBe
Posted

Exactly what i am looking for.

I appreciate you can help me to control the size of text

Posted

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

Posted

I used Demo2.

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

Posted
I used Demo2.

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

 

See update code at post # 2

 

HTH

Posted

Awesome!

 

Thanks agian pBe for your efforts

 

I have changed factor for mm 0.000001 insted of 0.001 since it is area.

Posted
...Thanks agian pBe for your efforts

I have changed factor for mm 0.000001 insted of 0.001 since it is area.

 

Oh yeah.. silly me.. Glad i could help :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...