PDA

View Full Version : Dimension styles - Place text automatically



RyanAtNelco
3rd Nov 2009, 05:40 pm
Hey all,

Does anyone know of a lisp that goes through all the dimstyles and removes the option "place text manually". I want my measurment to automatically be centered on the dimension, and I frequently work with drawings that have many text styles that have the "place text manually" box checked off in the dimstyle properties.

Thanks!

Freerefill
3rd Nov 2009, 05:41 pm
I had the same problem not too long ago. Try this:





(defun c:fd( / ss eLst)
(princ "\nSelect dimensions: ")
(setq ss (ssget '((0 . "DIMENSION"))))
(if ss
(foreach forVar (vl-remove nil (mapcar '(lambda (x) (if (= (type (cadr x)) 'ENAME) (cadr x) '())) (ssnamex ss)))
(setq eLst (entget forVar))
(setq eLst (subst '(70 . 32) (assoc 70 eLst) eLst))
(entmod eLst)
(entupd forVar)
)
)
); Fix dimensions so text aligns in the center

RyanAtNelco
3rd Nov 2009, 05:46 pm
This is good, but it looks like it takes each individual dimension. Do you know of a way to edit the dimension styles, so that future dimensions you create will automatically be centered?

Freerefill
3rd Nov 2009, 05:56 pm
hmm.. if you go to the modify dimensions window (command: "DIMSTYLE"), modify the one you want then click on the "TEXT" tab, under "Text alignment" (bottom right corner) you should see a radio button. Check to make sure that "Aligned with dimension line" is selected.

I'm afraid I haven't done much with dimension styles, so I think that's the best I can tell you.

RyanAtNelco
3rd Nov 2009, 07:27 pm
I have some similar code provided by alanjt. I have highlighted what i think needs to be changed, but i am admittedly not very good at writing code yet.

(vl-load-com)
(defun C:dmanual ()
(vlax-for x (vla-get-TextStyles
(vla-get-activedocument (vlax-get-acad-object))
)
(princ)
(vla-setfont x "ARIAL" :vlax-False :vlax-False 0 32)
)
)

I think textstyles needs to be changed to dimstyles, and font x "ARIAL" :vlax-False :vlax-False 0 32 needs to be changed as well, but im not sure to what.

Any insight would be great!

alanjt
3rd Nov 2009, 07:40 pm
Look in the Dimstyle settings:

15275

RyanAtNelco
3rd Nov 2009, 08:20 pm
Alan,

That is what i have been doing, but i have some drawings that have many dimstyles and it is time-consuming to go through the whole list.

I am looking to do it with a lisp, but i do not know the correct vla-set command (does anyone have a list of these commands handy?). Am i correct in assuming i should change "textstyles" to "dimstyles" ?

alanjt
3rd Nov 2009, 09:24 pm
Alan,

That is what i have been doing, but i have some drawings that have many dimstyles and it is time-consuming to go through the whole list.

I am looking to do it with a lisp, but i do not know the correct vla-set command (does anyone have a list of these commands handy?). Am i correct in assuming i should change "textstyles" to "dimstyles" ?


This should get you started, can't edit current style (just how it is).


(defun test (#Name / #Style)
(and (setq #Style (entget (tblobjname "dimstyle" #Name)))
(entmod (append #Style (list (cons 288 0))))))

RyanAtNelco
3rd Nov 2009, 09:27 pm
Thanks Alan!

alanjt
3rd Nov 2009, 09:32 pm
Thanks Alan!

:) No problem.