francesc Posted February 18, 2015 Posted February 18, 2015 As I know the sides of a rectangle knowing only their perimeter. with lisp. Thank You Quote
ReMark Posted February 18, 2015 Posted February 18, 2015 Wouldn't you need to know something else about the rectangle like its area or length of a diagonal between two opposite corners? Two different size rectangles yet they both have the same perimeter length. The areas differ too. Quote
francesc Posted February 18, 2015 Author Posted February 18, 2015 Only me as the perimeter or area separately. Sometimes area or perimeter Quote
ReMark Posted February 18, 2015 Posted February 18, 2015 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? Quote
hanhphuc Posted February 19, 2015 Posted February 19, 2015 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 Quote
ReMark Posted February 19, 2015 Posted February 19, 2015 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? Quote
hanhphuc Posted February 19, 2015 Posted February 19, 2015 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!! perhaps OP wants to learn coding? Quote
ReMark Posted February 19, 2015 Posted February 19, 2015 Or the OP wanted to know the length and width of the rectangle since he already knew the area or the perimeter? Quote
hanhphuc Posted February 19, 2015 Posted February 19, 2015 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 Quote
BIGAL Posted February 20, 2015 Posted February 20, 2015 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)) Quote
hanhphuc Posted February 20, 2015 Posted February 20, 2015 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 Quote
Recommended Posts
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.