Jump to content

Recommended Posts

Posted (edited)

I'm using LISP to calculate the hatch area, but it keeps giving me errors, and it only works when I copy the code to a different file. Could you please take a look? Thank you.

 

Edited by sd2006
Posted

You need to check if the text style has a set height because the options in the TEXT command are not the same.

(defun C:ah () (hatcharea))
  (defun hatcharea ( / ss area i eo pt) 
  (setq
      ss (ssget '((0 . "hatch")))
      area 0
      i 0
  )
  (cond 
      ((and(and ss) (> (sslength ss) 0))
          (repeat (sslength ss)
          (setq eo (vlax-ename->vla-object (ssname ss i)))
          (setq area (+ area (vlax-get eo 'Area)))
          (setq i (+ i 1))
          )
          (while (not pt)(setq pt (getpoint "\nSelect area text insertion point >")))
          (setq area (/ area 1000000.))
          (if (zerop (cdr (assoc 40 (tblsearch "STYLE" (getvar "TEXTSTYLE")))))
              (command "_.text" pt "" "" (strcat "" (rtos area 2 2) " m²"))
              (command "_.text" pt "" (strcat "" (rtos area 2 2) " m²"))
          )
      )
  )
  (princ)
)

 

  • Thanks 1

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