Jump to content

length and width of rectangle as text


Hải_Duy

Recommended Posts

hi
i am looking for lisp that shows length x width like this drawing
i have been looking for similar lisps but they are not working the way i want, can someone help me to create such a lisp

image.png

Drawing2.dwg

Link to comment
Share on other sites

On 8/19/2023 at 5:30 AM, Hải_Duy said:

hi
i am looking for lisp that shows length x width like this drawing
i have been looking for similar lisps but they are not working the way i want, can someone help me to create such a lisp

image.png

Drawing2.dwg 40.5 kB · 2 downloads

 

Kent Cooper   , thank you 

 

 

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/length-and-width-of-rectangle-as-text/td-p/1369617

 

(Defun C:PLWH ; = PolyLine Width x Height [overall extent from bounding box]
   (/ plss n plobj LL UR delta)  
(setvar "dimzin" 0)
  (if (setq plss (ssget '((0 . "*POLYLINE"))))
    (repeat (setq n (sslength plss))
      (setq plobj (vlax-ename->vla-object (ssname plss (setq n (1- n)))))
      (vla-getBoundingBox plobj 'minpt 'maxpt)
      (setq
        LL (vlax-safearray->list minpt)
        UR (vlax-safearray->list maxpt)
        delta (mapcar '- UR LL)
      ); setq
      (command "_.text" "_c" ; [spelling out "_center" is taken as Osnap call]
  "_none"
  (mapcar '/
    (mapcar '+ (vlax-safearray->list minpt) (vlax-safearray->list maxpt))
    '(2 2 2)
  ); mapcar
  "" 0 ; accept default height, rotation 0
  (strcat (rtos (car delta) 2 3) " x " (rtos (cadr delta) 2 3)); first line of Text
  
  
); command
    ); repeat
  ); if
  (princ)
); defun

 

Link to comment
Share on other sites

13 hours ago, thecocuk07 said:

 

Kent Cooper   , thank you 

 

 

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/length-and-width-of-rectangle-as-text/td-p/1369617

 

(Defun C:PLWH ; = PolyLine Width x Height [overall extent from bounding box]
   (/ plss n plobj LL UR delta)  
(setvar "dimzin" 0)
  (if (setq plss (ssget '((0 . "*POLYLINE"))))
    (repeat (setq n (sslength plss))
      (setq plobj (vlax-ename->vla-object (ssname plss (setq n (1- n)))))
      (vla-getBoundingBox plobj 'minpt 'maxpt)
      (setq
        LL (vlax-safearray->list minpt)
        UR (vlax-safearray->list maxpt)
        delta (mapcar '- UR LL)
      ); setq
      (command "_.text" "_c" ; [spelling out "_center" is taken as Osnap call]
  "_none"
  (mapcar '/
    (mapcar '+ (vlax-safearray->list minpt) (vlax-safearray->list maxpt))
    '(2 2 2)
  ); mapcar
  "" 0 ; accept default height, rotation 0
  (strcat (rtos (car delta) 2 3) " x " (rtos (cadr delta) 2 3)); first line of Text
  
  
); command
    ); repeat
  ); if
  (princ)
); defun

 

this is this lisp, i found it yesterday 👏

Link to comment
Share on other sites

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