Create "DIMDIAMETER" and edit dimension text

Create "DIMDIAMETER" and edit dimension text

nitin.rathod3CW9S
Contributor Contributor
726 Views
6 Replies
Message 1 of 7

Create "DIMDIAMETER" and edit dimension text

nitin.rathod3CW9S
Contributor
Contributor

Hi,

I need help with LISP program that can editing the dimension to add text. Below is the screenshot to show what I'm trying to achieve here. 

I've also copied below the code I'm using to create diameter dimension to help you helping me.

 

2021-12-29_19-29-00.jpg

 

(defun AutoDimDia ( x pt-for-dim / circle pt-on-circle )
(if (and x ; get the last object
(= "CIRCLE" (cdr (assoc 0 (entget x)))) ; is it really a circle?
(setq pt-on-circle (polar (cdr (assoc 10 (entget x))) ; get circle's centre point
(cdr (assoc 40 (entget x))) ; get circle's radius
(* pi 0.5))) ; 45°

)
(command "_.DIMDIAMETER"
(list x ; just object is not enough, some commands needs both ename and point, combined into list '(ename (10 10 0))
pt-on-circle)
"_none" pt-for-dim) ; don't forget turn off OSNAPS
)
(princ)
)

0 Likes
Accepted solutions (2)
727 Views
6 Replies
Replies (6)
Message 2 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

Two issues I see with the code:

The (polar) function takes point, angle & distances arguments, but you have them in point, distance & angle order.

(* pi 0.5) is not 45° but 90°.

 

But in any case, Dimensioning commands all have a Text option for providing text other than just the measurement.  Add a call for the Text option, and for the content, give it:


(strcat "<>" "YourAddedText")

 

The "<>" stands for the measurement value.  Include a space at the beginning of " YourAddedText" if you want it separated a little from the measurement part.

Kent Cooper, AIA
0 Likes
Message 3 of 7

nitin.rathod3CW9S
Contributor
Contributor

Thanks for the real quick response @Kent1Cooper , how to find out the text option for "DIMDIAMETER"?

(vla-put-TextOverride dimObj newStr) can be used to change text but then it needs object of the dimension which I don't have using command line "DIMDIAMETER" method.

Do you think you can help me with the text option for the command I'm using from command line.?

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant

@nitin.rathod3CW9S wrote:

.... how to find out the text option for "DIMDIAMETER"?....


Just draw one manually, and watch for where the Text option is offered, and feed that in at the appropriate place in your code.

Kent Cooper, AIA
0 Likes
Message 5 of 7

Sea-Haven
Mentor
Mentor
Accepted solution

Like Kent this was from a post a few days ago where the dim was to have a number label. 

 

(command "dimaligned" (getpoint "\npt1") (getpoint "\nPt2") "T" (strcat "Dim " (rtos x 2 0) "\n <>") (getpoint "\nPick offset"))

 

If you want metric and imperial then will need to say know radius/dia then have a look up list, so the (strcat part will be both imperial and metric. 15/16=23.8125 not 24. The example is 2 lines of dims

 

SeaHaven_0-1640834241222.png

NOTE "T"

0 Likes
Message 6 of 7

nitin.rathod3CW9S
Contributor
Contributor

Thanks a lot for the help.

0 Likes
Message 7 of 7

nitin.rathod3CW9S
Contributor
Contributor
Thanks for the sample man
0 Likes