Jump to content

Draw Required Area With Required Dimensions?


KumKum

Recommended Posts

Hi I work in a company, people come to us with their plot registry, on which are the dimensions (north,east,south,west) and area of their plots. But there are no angles. For example, a plot of 25 * 10 meters with an area (according to the mathematical calculations) should be 250 square meters. But 244.95 is listed on the registry.
My question is how do I quickly draw this plot (according to the registry) in AutoCAD? Is there any lisp for this?

Link to comment
Share on other sites

(defun c:sz (/ a ar b ip p1 p2 x y)
  (setq x (getdist "\n X dimension? :")
	y (getdist "\n Y dimension? :")
	ar (getreal "\n Area? :")
	a  (sqrt (/ ar (/ x y)))
	b  (* a (/ x y))
	ip (getpoint "\n Insert rectangle:")
	p1 (polar ip 0 a)
	p2 (polar p1 (* pi 0.5) b)
	)
  (command "rectang" ip p2)
  (princ))

Try this

Link to comment
Share on other sites

Or, it could be a parallelogram

(defun c:sx (/ ar h ip l p1 p2 p3 p4 x y)
  (setq	x  (getdist "\n X dimension? :")
	y  (getdist "\n Y dimension? :")
	ar (getreal "\n Area? :")
	ip (getpoint "\n Insert figure:")
	h  (/ ar x)
	l  (sqrt (- (expt y 2) (expt h 2)))
	p1 (polar ip 0 x)
	p2 (polar ip 0 l)
	p3 (polar p2 (* pi 0.5) h)
	p4 (polar p3 0 x)
  )
  (command "pline" p1 ip p3 p4 "c")
  (princ))

 

Link to comment
Share on other sites

You could also use something like this to draw whatever shape then scale to get the area you want.

(defun c:scaletoarea (/ _getarea a a2 ll o s)
  ;; RJP » 2020-12-09
  ;; Scales an object to a desired area
  (defun _getarea (e / a)
    (if	(vl-catch-all-error-p (setq a (vl-catch-all-apply 'vlax-curve-getarea (list e))))
      0
      a
    )
  )
  (if (and (setq s (ssget ":L" '((0 . "~INSERT")))) (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)
)(vl-load-com)

 

Edited by ronjonp
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...