Lisp for Dimensions in auto lisp for rectangle center in cross section

Lisp for Dimensions in auto lisp for rectangle center in cross section

swapnilumardand
Observer Observer
698 Views
4 Replies
Message 1 of 5

Lisp for Dimensions in auto lisp for rectangle center in cross section

swapnilumardand
Observer
Observer

I have small situation i want auto dim in this LISP and also required insert block in center of rectangle as per attached file 

 

(defun c:cnt (/ pnt1 pnt2 pnt3 pt4 )
(princ "\n \n ")
(setq pnt1 (getpoint "\nFirst corner ")) (terpri)
(setq pnt3 (getcorner pnt1 "\nOpposite corner...")) (terpri)
(setq pnt2 (list (car pnt1) (cadr pnt3)))
(setq pnt4 (list (car pnt3) (cadr pnt1)))
(command "PLINE" pnt1 pnt2 pnt3 pnt4 "c")
(command "line" pnt1 pnt3 "") ; draw the square
(command "line" pnt2 pnt4 "") ; draw the square
(princ "\n \n ")(princ)
) ; end of the defun

 

swapnilumardand_1-1643459947183.png

 

0 Likes
Accepted solutions (1)
699 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

That is not difficult, but:

 

Should the Dimensions always be from the center to the bottom edge and the left edge, or would any horizontal and vertical direction from the center suffice?

 

What should determine the dimension-line locations of the Dimensions?

 

Would the Block always be at scale factors of 1?

 

Would the current Layer and Dimension Style always be appropriate, or should specifying those be built in?

Kent Cooper, AIA
0 Likes
Message 3 of 5

pbejse
Mentor
Mentor
Accepted solution

@swapnilumardand wrote:

I have small situation i want auto dim in this LISP and also required insert block in center of rectangle,,,


(defun c:cnt (/ _Mid2p pnt1 pnt2 pnt3 pnt4 left mid bottom)
  (defun _Mid2p (p1 p2)
    (mapcar (function (lambda (a b) (/ (+ a b) 2.))) p1 p2)
  )
  
  (princ "\n \n ")
  (setq pnt1 (getpoint "\nFirst corner "))
  (terpri)
  (setq pnt3 (getcorner pnt1 "\nOpposite corner..."))
  (terpri)
  (setq pnt2 (list (car pnt1) (cadr pnt3) 0.0))
  (setq pnt4 (list (car pnt3) (cadr pnt1) 0.0))
  (command "PLINE" "_non" pnt1 "_non" pnt2 "_non" pnt3 "_non" pnt4 "c")
  (command "line" "_non" pnt1 "_non" pnt3 "")		; draw the square
  (command "line" "_non" pnt2 "_non" pnt4 "")		; draw the square

	(setq left (_Mid2p pnt1 pnt2))
  	(setq mid  (_Mid2p pnt1 pnt3))
  	(setq bottom (_Mid2p pnt1 pnt4))
  	(command "_dimlinear" "_non" left "_non" mid "_non" mid )
        (command "_dimlinear" "_non" bottom "_non" mid "_non" mid )
  	(command "._insert" "cenblk" "_non" mid "1" "0")
  
  (princ "\n \n ")
  (princ)
)

HTH

 

Message 4 of 5

swapnilumardand
Observer
Observer

Thanks a lot for help also i have small query in this command dim should be not in center it is require extended from center point

0 Likes
Message 5 of 5

pbejse
Mentor
Mentor

@swapnilumardand wrote:

Thanks a lot for help also i have small query in this command dim should be not in center it is require extended from center point


You are welcome.

Guess that can be arranged. There are a couple of ways to do that.

1. Fixed value

2. By defined height of the dimension string

3. User prompt

.....

Try any of the three options and post your code here.

 

0 Likes