structo Posted June 29, 2020 Posted June 29, 2020 Hi All.. I need lisp routine by Clicking Two Diagonal corners like Rectangle, After finished picking need to display that rectangle area result at Command line. and disappear the drawn rectangle. Procedure for executing lisp is 1. Pick point 1 2.Pick at Final corner point 2 3. And Displays the Rectangle area result at Command line & Disappear drawn the rectangle. Kindly help me. i have to check the areas between different points. Quote
Tharwat Posted June 29, 2020 Posted June 29, 2020 Area on the fly. (defun c:aof (/ 1p 2p) ;; aof = Area on the fly. ;; (and (setq 1p (getpoint "\nSpecify base point : ")) (setq 2p (getcorner "\nOpposite point : " 1p)) (princ (* (distance 1p (list (car 2p) (cadr 1p))) (distance 2p (list (car 2p) (cadr 1p)))) ) ) (princ) ) 1 Quote
structo Posted June 30, 2020 Author Posted June 30, 2020 (edited) 13 hours ago, Tharwat said: Quote Thank you very much, As said it is Area on fly Is it Possible? same Area result at command line can we see also length = , Width = Edited June 30, 2020 by structo Quote
BIGAL Posted June 30, 2020 Posted June 30, 2020 Here is another version posted over at AUGI. Look at Tharwat code and have a go. Can get the 4 points of the rectang then use Tharwat code and modify the Alert shown here. (defun c:2ptarea ( / obj ) (command "rectang" (getpoint "pick p1 then drag") pause) (setq obj (vlax-ename->vla-object (entlast))) (alert (strcat "area is " (rtos (vla-get-area obj)))) (command "erase" "l" "") (princ) ) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast))))) (setq p1 (nth 0 co-ord) p2 (nth 1 co-ord) p3 (nth 2 co-ord) p4 (nth 3 co-ord) ) Ps have a go 1st, I have it solved and happy to compare. Quote
Tharwat Posted June 30, 2020 Posted June 30, 2020 (defun c:aof (/ 1p 2p wd ht) ;; aof = Area on the fly. ;; (and (setq 1p (getpoint "\nSpecify base point : ")) (setq 2p (getcorner "\nOpposite point : " 1p)) (setq wd (distance 1p (list (car 2p) (cadr 1p))) ht (distance 2p (list (car 2p) (cadr 1p))) ) (princ (strcat "\nWidth = " (rtos wd 2 4) " Height = " (rtos ht 2 4) " Area = " (rtos (* wd ht) 2 4) ) ) ) (princ) ) 1 Quote
Tharwat Posted June 30, 2020 Posted June 30, 2020 1 hour ago, structo said: It is awesome, Thank you Tharwat You're welcome anytime. 2 Quote
BIGAL Posted July 1, 2020 Posted July 1, 2020 With visual drag box. (defun c:2ptarea ( / co-ord x y ) (command "rectang" (getpoint "pick p1 then drag") pause) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast))))) (setq p1 (nth 0 co-ord) p2 (nth 1 co-ord) p3 (nth 2 co-ord) p4 (nth 3 co-ord) ) (setq x (abs(- (car p1)(car p2)))) (setq Y (abs (- (cadr p1)(cadr p4)))) (setq parea (* x y)) (alert (strcat "area is " (rtos parea 2 2) " Length is " (rtos X 2 2) " Height is " (rtos Y 2 2))) (command "erase" "l" "") (princ) ) 1 Quote
hanhphuc Posted July 1, 2020 Posted July 1, 2020 another, delta (defun c:tt (/ p1 p2 en obj ) (and (setq p1 (getpoint "Specify point ")) (setq p2 (getcorner p1 "opposite corner ")) (setq en (entmakex (list '(0 . "LINE") (cons 10 p1) (cons 11 p2)))) (setq obj (vlax-ename->vla-object en)) (princ (strcat "\nArea=" (rtos (apply '* (mapcar '(lambda (a b) (+ a (abs b))) '(0 0) (vlax-get obj 'delta) ) ) 2 3 ) " M\U+00B2" ) ) (entdel en) ) (princ) ) WCS 3 Quote
structo Posted July 2, 2020 Author Posted July 2, 2020 Nice hanhphuc & BIGAL.. How to see the result in Bold font style? Quote
hanhphuc Posted July 2, 2020 Posted July 2, 2020 (edited) 14 hours ago, structo said: Nice hanhphuc & BIGAL.. How to see the result in Bold font style? Font style in command line? 0 acFontRegular 1 acFontItalic 2 acFontBold 3 acFontBoldItalic (vla-put-textfontstyle (vla-get-display (vla-get-preferences (vlax-get-acad-object))) acFontBold ;2 ) p/s: BCAD; error : Automation Error E_NOTIMPL; [IAcadPreferencesDisplay] function [TEXTFONTSTYLE] not implemented yet Edited July 2, 2020 by hanhphuc Quote
BIGAL Posted July 3, 2020 Posted July 3, 2020 Structo the idea behind using Alert rather than princ is that it pops up in front of you no need to look down on command line. Quote
structo Posted July 3, 2020 Author Posted July 3, 2020 hi hanhphuc, I dont want Entire command line in bold style, after executing lisp, result should be in bold style. Quote
hanhphuc Posted July 3, 2020 Posted July 3, 2020 (edited) 8 hours ago, structo said: hi hanhphuc, I dont want Entire command line in bold style, after executing lisp, result should be in bold style. Is not a good practice. alert as BIGAL easier (defun c:tt () ;;<snippet> ;;acFontBold <-- refer to previous snippet (getstring "\nEnter to continue.. ") ;;acFontRegular (princ) ) i prefer ( grtext -1 "AREA= xxx " ) Edited July 3, 2020 by hanhphuc Quote
pBe Posted July 4, 2020 Posted July 4, 2020 (Defun c:Demo (/ p1 p2) (if (and (setq p1 (getpoint "Specify point ")) (setq p2 (getcorner p1 "opposite corner ")) ) (princ (strcat "\nArea=" (rtos (* (abs (- (Car p1) (Car p2))) (abs (- (Cadr p1) (Cadr p2))) ) 2 3 ) ) ) ) (princ) ) Quote
BIGAL Posted July 5, 2020 Posted July 5, 2020 Pbe its posted elsewhere as well, and in other post wants Area, Length & Height. Think it was forums/Autodesk. Quote
pBe Posted July 5, 2020 Posted July 5, 2020 (edited) 2 hours ago, Jonathan Handojo said: Apologies guys... GrText Demo 3 I knew from the start that this discussion will inevitably leads to that link you posted. Edited July 5, 2020 by pBe Quote
Lee Mac Posted July 5, 2020 Posted July 5, 2020 2 hours ago, pBe said: I knew from the start that this discussion will inevitably leads to that link you posted. 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.