Originally Posted by
Tom Beauford
That's different that what I thought. To modify the actual Dimension Styles modify the entity list of the first one in the table with
Code:
(tblnext "DIMSTYLE" T)
then loop through modifying the rest using
Code:
(tblnext "DIMSTYLE")
Might be helpful if you attached small before and after drawings with just a handful of dimensions to test code on.
Ok, so I think you broke me out of the Google issue I was having:
Code:
(setq Old_cmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
;; getting first dimstyle created
(setq sty (tblnext "DIMSTYLE"))
;; getting dimstyle name
(setq sty(cdr (assoc 2 sty)))
(while (/= sty nil) ;; if dimstyle is not nil then proceed
(setq sty (tblsearch "DIMSTYLE" sty)) ;; searching dimstyle dialog box for dimstyle name
(if (= (cdr (assoc 2 sty)) "Standard");; if the dimstyle name equals standard then go to the next dimstyle and get its name
(progn
(setq sty (tblnext "DIMSTYLE"))
(setq sty(cdr (assoc 2 sty)))
);; end of progn
(progn
(setvar "dimtad" 1);; If the dimstyle name is not Standard then set the dimtad to 1
(command "-dimstyle" "s" (cdr (assoc 2 sty)) "y");; save the newly created dimstyle with the same name and new dimscale
(setq sty (tblnext "DIMSTYLE"));;Get the next dimstyle
(setq sty (cdr (assoc 2 sty)));; Get dimstyle name and repeat while until value is nil
);; end of progn
);; end of if
);; end of while
(setvar "cmdecho" Old_cmdecho);; when value is nil reset the cmdecho variable to its original value
(princ)
)
This skips Standard, which I coincidentally actually want, then modifies that DIMTAD variable. However, nothing I change that to makes ANY difference. This script ORIGINALLY changed dimscale to 2, and it worked fine. I changed DIMSCALE to DIMTAD (mouseover on the item claims this is the variable), and messed with the numbers, but nothing ever changes.
Attached .DWG shows an example of the silliness of multiple dimension styles, but it shouldn't be a problem. If you go into the dimension styles and update all of the DIMSTYLE* types to have Text Placement as Vertical and Text Alignment as Horizontal, the drawing will look exactly as I want it to.
If this is somehow easier, I use this code to edit the SCALE and LINEAR SCALE; I assume it would be easy to edit for someone smarter than me. I don't know how anyone knows what the property names are:
Code:
(vl-load-com)
;; © Lee Mac 2010
(defun *error* ( msg )
(and doc (_EndUndo doc))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ)
)
(defun _StartUndo ( doc ) (_EndUndo doc)
(vla-StartUndoMark doc)
)
(defun _EndUndo ( doc )
(if (= 8 (logand 8 (getvar 'UNDOCTL)))
(vla-EndUndoMark doc)
)
)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (ssget "_X" '((0 . "*DIMENSION,LEADER")))
(progn
(setq *scl*
(cond
(
(getdist
(strcat "\nSpecify Linear Scale Factor <"
(rtos
(setq *scl* (cond ( *scl* ) ( 1.0 )))
)
"> : "
)
)
)
( *scl* )
)
)
(setq *oscl*
(cond
(
(getdist
(strcat "\nSpecify Overall Scale Factor <"
(rtos
(setq *oscl* (cond ( *oscl* ) ( 1.0 )))
)
"> : "
)
)
)
( *oscl* )
)
)
(_StartUndo doc)
(vlax-for o (setq ss (vla-get-ActiveSelectionSet doc))
(mapcar
(function
(lambda ( prop value )
(if (vlax-property-available-p o prop)
(vlax-put-property o prop value)
)
)
)
'(LinearScaleFactor ScaleFactor) (list *scl* *oscl*)
)
)
(vla-delete ss)
(_EndUndo doc)
)
)
(princ)