Jump to content

Recommended Posts

Posted

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.

Area Lisp by draw rectangle.jpg

Posted

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

 

  • Like 1
Posted (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 by structo
Posted

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.

 

Posted
(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)
)

 

  • Thanks 1
Posted
1 hour ago, structo said:

It is awesome, Thank you Tharwat 😊👍

You're welcome anytime. :) 

  • Like 2
Posted

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

 

  • Like 1
Posted

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

  • Like 3
Posted

Nice hanhphuc & BIGAL..

How to see the result in Bold font style?

Posted (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 by hanhphuc
Posted

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.

Posted

hi hanhphuc,

 

I dont want Entire command line in bold style, after executing lisp, result should be in bold style.

 

 

Posted (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 by hanhphuc
Posted
(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)
)

 

Posted

Pbe its posted elsewhere as well, and in other post wants Area, Length & Height. Think it was forums/Autodesk.

Posted (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 by pBe
Posted
2 hours ago, pBe said:

 

I knew from the start that this discussion will inevitably leads to that link you posted. 🙂

 

 

🙂

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