Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Automatic Dimension

Anonymous

Automatic Dimension

Anonymous
Not applicable

Hi everyone,

I used to have a LISP routine that would place dimension of the height and width of a rectangle, just by selecting the rectangle, or poly line.

I do not have that LISP anymore, and have looked everywhere on the internet for something similar, but cannot find exactly what I used to have. I know alittle about editing or modifying a LISP routine, but don't feel comfortable in editing the ones I have found, that worked somewhat for what I was looking for.

Does anyone know where I could find such a routine, to simply place dimensions for the height and width of any polyline rectangle? Ive attached drawing of what I am looking for. Thanks in advance

0 Likes
Reply
Accepted solutions (1)
18,485 Views
29 Replies
Replies (29)

Sea-Haven
Mentor
Mentor

Whilst kent has given you an excellent lisp here is a simpler version that draws the rectang and dimensions in one go. Like kent's it may need a couple of little changes. It was done as a lisp exercise.

 

; simple draw a box and dimension it 
; By Alan H March 2019
' info@alanh.com.au

(defun ah:box ( / pt1 pt2 pt3 ahl ahh ahoff )
(setq oldsnap (getvar 'osmode))
(setq oldang (getvar 'angdir))
(setq pt1 (getpoint "\nPick lower left"))
(setvar 'osmode 0)
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Simple rectang" "Enter length" 8 7 "1" "Enter height " 8 7 "2")))
(setq ahL (atof (nth 0 ans)))
(setq ahH (atof (nth 1 ans)))
(setq pt2 (polar pt1 0.0 ahl))
(setq pt3 (polar pt2 (/ pi 2.0) ahH))
(command "rectang" pt1 pt3)
(setq ahoff (* 2.0 (* (getvar 'dimasz)(getvar 'dimscale)))) ; change offset as required
(setq pt4 (polar pt2  (* pi 1.5) ahoff)) 
(command "dim" "hor" pt1 pt2 pt4 "" "exit")
(setq pt4 (polar pt3 0.0 ahoff))
(command "dim" "Ver" pt2 pt3 pt4 "" "exit")
(setvar 'osmode oldsnap)
)
(ah:box)

 You need the multi getvals for the box size. 

0 Likes

m.pahee
Explorer
Explorer

Greate work. Is it possible to get the lisp file of the solution.

 

Thanks 

PM

0 Likes

Kent1Cooper
Consultant
Consultant

@m.pahee wrote:

Greate work. Is it possible to get the lisp file of the solution. ....


The link is in Message 2.  You can decide whether to use the adjustment in the Message marked as the Solution.

Kent Cooper, AIA
0 Likes

hoangan_alain15
Enthusiast
Enthusiast

@Kent1Cooper I read this topic and I very appreciate what you've done. I have once more things, Can you solve it?

Thank you so much

hoangan_alain15_0-1618380753639.png

 

0 Likes

Kent1Cooper
Consultant
Consultant

It won't always do the same two edges -- when limited to two [modification at the accepted Solution Message], it does the first two segments, so it depends on where the Polyline starts and in which direction it goes.  If made with the RECTANG command, it depends on which two opposite corners were picked, and in which order.

 

If you always want the left and top sides, that could be done with some calculation.  I can't work on that today, but maybe later.

Kent Cooper, AIA
0 Likes

hoangan_alain15
Enthusiast
Enthusiast

ok, thank you so much. It's not urgent, so you can do when available.

0 Likes

Anonymous
Not applicable

Like kent if you look at what I posted it uses the corner points so just change the code to be left handed vertical dim. 

just change these for angle and pt order
(setq pt4 (polar pt3 0.0 ahoff))
(command "dim" "Ver" pt2 pt3 pt4 "" "exit")
0 Likes

hoangan_alain15
Enthusiast
Enthusiast

Thank you so much. But I don't know how to run this lisp. Please teach me!

0 Likes

Anonymous
Not applicable

The box .lsp is an example you just need to rearrange the pt numbers to work change the direction pt4 as you need pt4 in your dimension, (setq pt4 (polar pt2 (* pi 1.5) ahoff)) make it say pt3, then the dim will be pt1 pt4 pt3, you need to use pt1 as well rather than pt2.

 

screenshot380.png

0 Likes

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... If you always want the left and top sides, that could be done with some calculation.  ....


Try the attached DimRectLeftTop.lsp with its DRLT command.  Check for comments [especially EDIT comments] in the code.

 

It could be enhanced further -- inform the User of any Polylines selected that were not rectangular, work in other UCS's, create or set a specific Dimension Style instead of using whatever is current, etc.

Kent Cooper, AIA
0 Likes