Dear Peter,
I saw you lisp for dimension edit. it is very usefull to me. Iam searching for a lisp
I want draw some circles(holes) on a selected diagonal / horizontal / vertical line by required dimensions.Not equal.
I have below mentioned lisps, but circles placing on horizontal or vertical lines, not placing on diagonal lines.
Please rectify my lisp or give new lisp to me. It is very helpful to me. May be I couldn't explain what I want,
I am sending a drawing what i want to draw exactly.Please find the attachment.
I am very sorry for my poor english.
My Lisp Code :
(defun c:hh ( / cols dir rows rowd rowh rowv rowo hole )
(initget 0 "Left Right")
(setq dir (getkword "\nEnd of Object (Left/Right) <L>: ")
rowd (getdist (strcat "\nGauge Line from Heel <" (rtos 3) ">: "))
rowo (getdist (strcat "\nSheare Edge <" (rtos 25) ">: "))
rowh (getdist (strcat "\nHole to Hole / center <" (rtos 3) ">: "))
cols (getint "\nNo. of Holes <1>: ")
hole (getdist (strcat "\nHole diameter " (rtos 17.5) ">: "))
)
(if (= dir nil)(setq dir "Left"))
(if (= rows nil)(setq rows 0))
(if (= cols nil)(setq cols 1))
(if (= rowd nil)(setq rowd 3))
(if (= rowh nil)(setq rowh 3))
(if (= rowo nil)(setq rowo 25))
(if (= hole nil)(setq hole 17.5))
(setq ins (getpoint "\nSelect insertion point: "))
(if (= dir "Left")
(progn
(setq ins (polar ins 0 rowo))
(repeat cols
(setq lstpnt (polar ins (* pi 1.5) rowd))
(entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
(repeat (1- rows)
(setq lstpnt (polar lstpnt (* pi 1.5) rowv))
(entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
)
(setq ins (polar ins 0 rowh))
)
)
(progn
(setq ins (polar ins pi rowo))
(repeat cols
(setq lstpnt (polar ins (* pi 1.5) rowd))
(entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
(repeat (1- rows)
(setq lstpnt (polar lstpnt (* pi 1.5) rowv))
(entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
)
(setq ins (polar ins pi rowh))
)
)
)
(princ)
)
I would suggest you start a new thread. The question is not on the subject of this one.
For that new topic: Are the Circle spacings always the same? Are the selected Lines always the same length? Will you be selecting that yellow dashed-dotted Line? Will the two Circles close together always be at the start of the Line, or might they sometimes need to be at the other end?
Hi, this one's great! thanks. Would you mind to tweak the code a bit to help me more? I'd like to override the dimmension by mathematical expression "<> + 420". I need to make a longitudinal cross section with many dimensions and a defined base ground. and I need to add the given base ground to the dimension measured by autocad. I would appreciate your help, thank you! Lucie
@tom wrote:
Hi, this one's great! thanks. Would you mind to tweak the code a bit to help me more? I'd like to override the dimmension by mathematical expression "<> + 420". I need to make a longitudinal cross section with many dimensions and a defined base ground. and I need to add the given base ground to the dimension measured by autocad. I would appreciate your help, thank you! Lucie
[I haven't seen *pkirill around here recently [that's a more-than-12-year-old post, after all], but....]
If you want it to literally add text with the plus sign and the 420, you should be able to just replace their "<> TYP" with that string of yours [and presumably change the command name]. But do you really want the text changed to a single number that's the mathematical result of adding 420 to the measured dimension? That would be a different problem, but not too difficult to do. A Search may even find something that does it already.
@tom wrote:
Hi, this is Lucie actually, writing from my boyfriend's account. Sorry 🙂 exactly, I need to make math addition of these two values: original dim value + number I will choose. Example: orig. Autocad dim value is 2.91m, the lisp will add 499m, final result then 501.91m. Is it possible? Thanks, Lucie
This adjustment to *pkirill's code seems to do that. I changed the command name and some variable names to be more meaningful [to me, at least], but you'll get the idea. The changes relevant to the question are shown in red. [You can even use a negative constant, if you want.]
(defun c:DTAC (/ addon dimss c ddata); = Dimension Text: Add Constant value
(setq
addon (getreal "\nConstant value to add to text of selected Dimension(s): ")
dimss (ssget ":L" '((0 . "DIMENSION")))
c -1
); setq
(repeat (sslength dimss)
(setq
ddata (entget (ssname dimss (setq c (1+ c))))
ddata
(subst
(cons 1 (rtos (+ (cdr (assoc 42 ddata)) addon) 2 2)); <-- adjust mode/precision as desired
(assoc 1 ddata)
ddata
); subst & adjusted ddata
); setq
(entmod ddata)
); repeat
(princ)
); defun
Wow! Kent, you're a king! thank you so much, this will save me a lot of time doing this manually... thanks again 🙂
@lawrebewhat wrote:
How do i get the lisp file to work in my dimensions.
Welcome to these Forums!
There are lots of threads here, and elsewhere, about how to save and load and use AutoLisp command definitions, but quickly:
Copy the code parts out and Paste them into a plain-text editor such as Notepad. Save to a file with a .lsp filetype ending. In a drawing, use the APPLOAD command, navigate to where you saved that file, select and Load it. Then to use it, type the command name, which is what follows the (defun c: [in this case, DTAC].
Petervose,
I like your lisp, any chance of getting an alternative that enters the dimensions "measurement" value into the text override and allows selection of multiple dimensions so i can do lots at once?
In simple terms i want to be able to fix the value of the dimension and be able to change the grip positions without the displayed value changing. So if i have a 2000mm long dimension, then drag it to say 500mm long, i still want it to show 2000. TIA.
@jonkugler44 wrote:
Petervose,
I like your lisp, any chance of getting an alternative that enters the dimensions "measurement" value into the text override and allows selection of multiple dimensions so i can do lots at once?
In simple terms i want to be able to fix the value of the dimension and be able to change the grip positions without the displayed value changing. So if i have a 2000mm long dimension, then drag it to say 500mm long, i still want it to show 2000. TIA.
This came up before many times, you could find more routines doing this. Here is my version.
(defun c:DimValueToOverride ( / ss i ent bent ed txt pos) (if (setq ss (ssget "_:L" '((0 . "DIMENSION")))) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i))) bent (tblobjname "BLOCK" (cdr (assoc 2 (entget ent))))) (while (setq bent (entnext bent)) (if (= (cdr (assoc 0 (setq bdef (entget bent)))) "MTEXT") (progn (setq txt (cdr (assoc 1 bdef))) (if (setq pos (vl-string-search ";" txt)) (setq txt (substr txt (+ 2 pos))))))) (entmod (subst (cons 1 txt) (assoc 1 (entget ent)) (entget ent))))) (princ) )
@jonkugler44 wrote:
.... an alternative that enters the dimensions "measurement" value into the text override ....
That sounds like a really bad idea for a variety of reasons, but if:
A] you have a carefully-considered legitimate reason to need to do it, and
B] your current Units format and precision are the same as those in the Dimension Style definition(s), and
C] the selected Dimensions won't ever already have an override that you don't want replaced,
it can be as simple as this:
(defun C:DIMMVO (/ ss n dim ddata) ; = DIMension Measured Value as Override (if (setq ss (ssget "_:L" '((0 . "DIMENSION")))) (repeat (setq n (sslength ss)) (setq ddata (entget (ssname ss (setq n (1- n))))) (entmod (subst (cons 1 (rtos (cdr (assoc 42 ddata)))) (assoc 1 ddata) ddata)) ); repeat ); if (princ) ); defun
That could be enhanced to pull the Units format and precision from the Dimension Style definition if those might differ from current settings, as well as get the usual enhancements [error handling, Undo begin/end wrapping, etc.].
Many thanks Kent1Cooper and BeekeeCZ. Both of your lisps achieve what i need to. I like the DimValueToOverride better as it retains pre-existing prefix and suffix overrides and maintains precision value. Thanks so much for your help guys!
sir
i need to select multiple dimension at a time and want to feed different value for each dimension
if that possible please give me the code please
Thanks