Jump to content
prax3des

rescale Areas ?

Recommended Posts

prax3des

Good afternoon everyone.
Sometimes I run into the following problem.
I have a room of X square meters, but in autocad it indicates other meters. Is there a lisp that can help me rescale to get those square meters?
Attached sample dwg

Drawing1.dwg

Share this post


Link to post
Share on other sites
ronjonp
Posted (edited)

Try this:

(defun c:scaletoarea (/ _getarea a a2 ll o s ur)
  ;; RJP » 2020-06-30
  (defun _getarea (e / a)
    (if	(not (vl-catch-all-error-p (setq a (vl-catch-all-apply 'vlax-curve-getarea (list e)))))
      a
      0.
    )
  )
  (if (and (setq s (ssget ":L")) (setq a (getreal "\nEnter desired area: ")))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (if (/= 0 (setq a2 (_getarea e)))
	(progn (vla-getboundingbox (setq o (vlax-ename->vla-object e)) 'll 'ur)
	       (setq ll (mapcar '+ (vlax-safearray->list ll) (vlax-safearray->list ur)))
	       (vlax-invoke o 'scaleentity (mapcar '/ ll '(2 2 2)) (sqrt (/ a a2)))
	)
      )
    )
  )
  (princ)
)

 

Edited by ronjonp

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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