Author Topic: rectangle auto dimension  (Read 1916 times)

0 Members and 1 Guest are viewing this topic.

dgcad

  • Guest
rectangle auto dimension
« on: January 30, 2016, 10:02:50 AM »
Hello,

I found this useful lisp of fixo. How can you modify this lisp?
The lisp created the dimension of a rectangle on the left side and above.
I would like to have the dimension down and right.


Thank you for your help



(defun C:demo (/ centpt coords elist en hgt p1 p2 p3 ss)
 
(command "_.zoom" "_e")
  (if (zerop (getvar "dimtxt"))
        (setq hgt 2.5)
        (setq hgt (getvar "dimtxt")))
  (if
(setq ss (ssget "_X" (list (cons 0  "LWPOLYLINE")(cons 70  1)(cons 90  4))))

(while
  (setq en (ssname ss 0))
  (setq elist (entget en))
  (setq coords (vl-remove-if (function not)(mapcar (function (lambda(x)(if (= 10 (car x))(cdr x))))elist)))
  (setq CentPt (mapcar (function (lambda(a b)(/ (+ a b )2)))(car coords )(caddr coords))
   )
 (setq coords (vl-sort Coords (function (lambda(a b)(> (angle CentPt a)(angle CentPt b))))))
  (setq p1 (cadr coords)p2(caddr coords) p3(last coords))
 (command "._dimlinear" "_non" p1"_non" p2"_non" (polar p2 pi (* 12 hgt)) )
  (command "._dimlinear" "_non" p2"_non" p3"_non" (polar p3 (/ pi 2) (* 12 hgt)) )
  (ssdel en ss))
(command "_.zoom" "_p")
)

 (princ)
  )



Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: rectangle auto dimension
« Reply #1 on: January 30, 2016, 10:30:07 AM »
Change:
Code: [Select]
p2(caddr coords)
to:
Code: [Select]
p2(car coords)


Change:
Code: [Select]
(polar p2 pi (* 12 hgt))
to:
Code: [Select]
(polar p2 (/ pi -2) (* 12 hgt))


Change:
Code: [Select]
(polar p3 (/ pi 2) (* 12 hgt))
to:
Code: [Select]
(polar p3 0 (* 12 hgt))


Also, please edit your post and enclose the code with code tags:

[code]Your code here[/code]

dgcad

  • Guest
Re: rectangle auto dimension
« Reply #2 on: January 30, 2016, 11:31:12 AM »
Hello ,

Marc many thanks for your fast answer, it works great.

Now I see that the distanz beetween text and line is static  "(x 12 hgt)".
I know , I can change this factor.

But, is it possible to make the distanze variablel ?

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: rectangle auto dimension
« Reply #3 on: January 30, 2016, 11:37:26 AM »
many thanks for your fast answer, it works great.

You're welcome  :-)

Now I see that the distanz beetween text and line is static  "(x 12 hgt)".
I know , I can change this factor.

But, is it possible to make the distanze variablel ?

Replace every instance of '12' with fac and then add the following as the second line in the program:
Code: [Select]
(setq fac (cond ((getreal "\nSpecify offset factor <12>: ")) (12)))
Also change the variable list on the first line from:
Code: [Select]
en hgt
to:
Code: [Select]
en fac hgt

dgcad

  • Guest
Re: rectangle auto dimension
« Reply #4 on: January 30, 2016, 03:13:25 PM »
Hi, Lee Mac

Now ist perfect.


Thanks very much

bilançikur

  • Newt
  • Posts: 82
Re: rectangle auto dimension
« Reply #5 on: February 01, 2016, 01:20:44 AM »
Off topic:

Reading this post reminded me of this:
https://www.theswamp.org/index.php?topic=48828.0

Wich is almost 1 year ago now.