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
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
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.
@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
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.
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")
Thank you so much. But I don't know how to run this lisp. Please teach me!
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.
@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.
Can't find what you're looking for? Ask the community or share your knowledge.