Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Automatic Dimension

29 REPLIES 29
SOLVED
Reply
Message 1 of 30
Anonymous
17347 Views, 29 Replies

Automatic Dimension

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

29 REPLIES 29
Message 21 of 30
Sea-Haven
in reply to: Anonymous

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. 

Message 22 of 30
m.pahee
in reply to: Anonymous

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

 

Thanks 

PM

Message 23 of 30
Kent1Cooper
in reply to: m.pahee


@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
Message 24 of 30

@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

 

Message 25 of 30

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
Message 26 of 30

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

Message 27 of 30
Anonymous
in reply to: hoangan_alain15

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")
Message 28 of 30
hoangan_alain15
in reply to: Anonymous

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

Message 29 of 30
Anonymous
in reply to: hoangan_alain15

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

Message 30 of 30
Kent1Cooper
in reply to: Kent1Cooper


@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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta