Jump to content

Recommended Posts

Posted

As I know the sides of a rectangle knowing only their perimeter.

with lisp.

 

Thank You

Posted

Wouldn't you need to know something else about the rectangle like its area or length of a diagonal between two opposite corners?

 

RectSizebyPerimeter.JPG

 

Two different size rectangles yet they both have the same perimeter length. The areas differ too.

Posted

Only me as the perimeter or area separately. Sometimes area or perimeter

Posted

So the lisp routine is started and the user is prompted to click on a rectangle and after making the pick the length and width of the rectangle is displayed?

 

Are you looking at CAD drawings containing rectangles that someone has labelled with either the length of the perimeter or the area? Is that it?

Posted
As I know the sides of a rectangle knowing only their perimeter.

with lisp.

 

Thank You

 

This?

(defun c:test (/ en l)
;perimeter for LWPolyline only 
 (if (and (setq en (car (entsel "\nPick entity..")))
   (setq lst (entget en)
	 l   (= (cdr (assoc 0 lst)) "LWPOLYLINE")
	 ) ;_ end of setq
   ) ;_ end of and
   (progn (setq l (vl-remove-if-not ''((x) (= (car x) 10)) lst))
   (princ
     (strcat "\nPerimeter= "
	     (rtos (apply '+ (mapcar ''((a b) (distance a b)) l
		(append (cdr l) (list (car l))))) 2 3) ; _ end of rtos
	     ) ;_ end of strcat
     ) ;_ end of princ
   ) ;_ end of progn
   ) ;_ end of if
 (princ)
 ) ;_ end of defun

Posted

Why bother with a custom lisp routine when the LIST command would give the user not only the perimeter but the area as well? And if one looks closely enough at the results one would be able to calculate the length and width.

 

Example of running the LIST command on a rectangle. Can you deduce the length and width?

 

ListRectangle.JPG

Posted
Why bother with a custom lisp routine when the LIST command would give the user not only the perimeter but the area as well?

good point mr.ReMark!!

:facepalm: perhaps OP wants to learn coding?

Posted

Or the OP wanted to know the length and width of the rectangle since he already knew the area or the perimeter?

Posted
Or the OP wanted to know the length and width of the rectangle since he already knew the area or the perimeter?

maybe you are correct. just wait OP to respond :)

Posted

If you use VLISP AREA & Length are direct answers as well as is it closed.

 

(setq ent (entsel "Pick pline"))
(setq obj (vlax-ename->vla-object (car ent)))
(setq area (vlax-get-property obj 'Area))
(setq Length (vlax-get-property obj 'length))
(setq closed (vlax-get-property obj 'Closed))

Posted
If you use VLISP AREA & Length are direct answers as well as is it closed.

 

(setq ent (entsel "Pick pline"))
(setq obj (vlax-ename->vla-object (car ent)))
(setq area (vlax-get-property obj 'Area))
(setq Length (vlax-get-property obj 'length))
(setq closed (vlax-get-property obj 'Closed))

 

Thanks BIGAL. visual lisp is so convenient!

here's another

(vlax-curve-getDistAtParam obj 
(vlax-curve-getEndParam obj)); perimeter 
(vlax-curve-getArea obj); area
(vlax-curve-isClosed obj); closed-p

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