A cheeky little LISP or VB request :-)

A cheeky little LISP or VB request :-)

Anonymous
Not applicable
897 Views
3 Replies
Message 1 of 4

A cheeky little LISP or VB request :-)

Anonymous
Not applicable

Hi,

 

Does anyone fancy a small, cheeky little task of putting together a LISP or VB routine for me. It's not a show-stopper in not having it but may help speed things up for me a little in my processing.

 

An even cheekier ask, if I can have a copy of the code afterwards then maybe, I can get my head around how it all works and amend it if needed or even write the next one, myself..... Thanks 🙂

 

Routine name: Items per area

Operations:

1) implement area command - allow for either 'select closed polygon' or 'create polygon from polyline'

2) divide resultant area figure by 1000000 (converts mm2 to m2 as our drawings are in mm units)

3) multiply the area figure by a 'multiplier' (number of items per m2 - keep previous entry as default if nothing new entered)

4) select position of where text is to go - Display resultant area x multiplier figure as a whole number and as MTEXT. Again, use default size & style etc

5) allow input of additional text on the same line

6) enter to accept

 

If I'm asking a bit much then SORRY if I've offended. Worth asking though perhaps?

 

Thanks in advance,

 

R

 

 

0 Likes
Accepted solutions (1)
898 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

Easy enough... object can be pre-selected.

 

(vl-load-com)

(defun c:ItemsPerArea ( / ent enl ara pnt str)
  
  (and (princ "\nPolyline required, or hit enter to draw")
       (setq ent (if (setq ent (ssget "_+.:E:S" '((0 . "LWPOLYLINE"))))
                   (ssname ent 0)
                   (progn
                     (setq enl (entlast))
                     (command "_.PLINE")
                     (while (> (getvar 'CMDACTIVE) 0)
                       (command PAUSE))
                     (if (equal enl (entlast))
                       nil
                       (entlast)))))
       (or *mlp*
           (setq *mlp* 2))
       (setq *mlp* (cond ((getreal (strcat "\nMultiplier <" (rtos *mlp*) "> ")))
                         (*mlp*)))
       (setq ara (vlax-curve-getArea ent))
       (setq ara (* *mlp* (/ ara 1000000.)))
       (setq pnt (getpoint "\nPlace the text: "))
       (setq str (lisped (rtos ara 2 2)))
       (entmakex (list (cons 0 "TEXT")
                       (cons 10  pnt)
                       (cons 11  pnt)
                       (cons 40 (getvar 'TEXTSIZE))
                       (cons 7 (getvar 'TEXTSTYLE))
                       (cons 1 str))))
  (princ)
  )

 

0 Likes
Message 3 of 4

Anonymous
Not applicable

Wow! That was quick!

 

Give me a moment to try it out. Easy when you know how I guess.

 

Thanks BeekeeCZ

0 Likes
Message 4 of 4

Anonymous
Not applicable

That's brilliant. Spot on!

 

Many thanks BeekeeCZ.

 

Now to try and get my head around trying to understand what it all means 😕

 

Cheers,

 

R

0 Likes