how to edit a dimension using autolisp

how to edit a dimension using autolisp

mike2334
Enthusiast Enthusiast
3,318 Views
7 Replies
Message 1 of 8

how to edit a dimension using autolisp

mike2334
Enthusiast
Enthusiast

I would like to use ddedit to change a dimension to a letter  so I can ask a question.

Michael Fyfe
0 Likes
Accepted solutions (2)
3,319 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

Not really understand you. But try this:

 

(defun c:OverrideDim ( / ss i ent bent ed txt pos)

  (if (and (setq ss (ssget "_:L" '((0 . "DIMENSION"))))
           (setq txt (getstring T "\nSpecify text to override dims: "))
           )
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (entmod (subst (cons 1 txt)
                     (assoc 1 (entget ent))
                     (entget ent)))))
  (princ)
)

Or do you actually want to type a letter to call the ddedit command? In that case, add the ALIAD to the ACAD.PGP file.

0 Likes
Message 3 of 8

mike2334
Enthusiast
Enthusiast

Thanks 

What I'm doing is making a lisp program to make an angle iron frame with holes.  In the first part of the program i'm getting the out side dimension of the angle iron frame say 36" x 12".  Then I putting that 36 x 12 rectangle on the screen with the dimension I just got.  Now I have to get the hole locations.  So I put a dimension in this drawing from center to say 3" to the left of center.  Its this dimension that I would like to change or edit  to be a letter so I can  use this latter to ask a question to get the dimension to locate the next hole. Then use (command ".erase" "L" "") and then use the same process to get the next hole and so on. 

Michael Fyfe
0 Likes
Message 4 of 8

Moshe-A
Mentor
Mentor

@mike2334  hi,

 

if you got some code, post it

 

moshe

 

0 Likes
Message 5 of 8

Kent1Cooper
Consultant
Consultant

@mike2334 wrote:

.... I have to get the hole locations.  So I put a dimension in this drawing from center to say 3" to the left of center.  Its this dimension that I would like to change or edit  to be a letter so I can  use this latter to ask a question to get the dimension to locate the next hole. Then use (command ".erase" "L" "") .... 


 

Study the Dimension command prompt sequence -- you can feed in a "_text" option and give it the letter in place of the measured-distance text, in the process of drawing it, rather than editing it afterwards.

 

But post an image or sample drawing illustrating what you want to end up with, and what kind of User input is necessary to determine it.  I suspect there's probably a much cleaner way to do it than to draw a temporary Dimension  only to almost immediately Erase it.

Kent Cooper, AIA
0 Likes
Message 6 of 8

mike2334
Enthusiast
Enthusiast

(defun C:123 (/)
(setvar "dimscale" 8)
(setvar "osmode" 0)
(setvar "dimzin" 8)
(setq p1 (list 10.00 10.00))
(setq p2 (polar(polar p1 0 36)(/ pi 2)22))
(Command ".Rectangle" p1 p2)
(Command ".Dimlinear"(polar p1 0 18)(polar p1 0 21)(polar p1 (* pi 1.5)6 ))
(command ".Zoom" "A")

;At this point I would like to change the 3" dim to a letter using lisp (ddedit or something) if I can?
;(initget 7)
;(setq bsize (getreal "\n Enter size {A}: "))

(command ".text" (polar p1 (* pi 1.5)12) 1.5 0 "At this point I would like to change the 3 inch dim")
(command ".text" (polar p1 (* pi 1.5)15) 1.5 0 "to a letter using lisp {ddedit or something} if I can?")

(command ".Zoom" "A")
(princ)
)

Michael Fyfe
0 Likes
Message 7 of 8

Moshe-A
Mentor
Mentor
Accepted solution

@mike2334 ,

 

you do not need to use ddedit (altough you can) instead use the option "text" of dimlinear command and feed any text value you want?!

 

change this:

(Command ".Dimlinear"(polar p1 0 18)(polar p1 0 21)(polar p1 (* pi 1.5)6 ))

 

to this:

(Command ".Dimlinear"(polar p1 0 18)(polar p1 0 21) "text" "A" (polar p1 (* pi 1.5) 6))

 

another way to to that is to get the entity database of the dimension and set a new text value but i do not want to confuse you right now with that.

 

moshe

 

Message 8 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

Easy enough version to set it backwards, to the last object created

 

(setpropertyvalue (entlast) "DimensionText" (getstring "\nLetter: "))

...for acad 2011+