Yeepeee!!! Excellent! Brilliant! Perfect!
Thanks a lot CADaver! You made my day! I owe you one!
Just to be sure, will there be any other cryptic behavior from autocad? I tried on a drawing that had overrides and it all went all smoothly, but are we sure that it will work on 100% drawings? What are the pitfalls that I might drop into?
So here is the complete functional code if anyone is interested in. Nice and clean with comments for learning easier from it.
(defun C:DSP (/ dimStyleIdentifier)
;So in this script, we will change all dimstyle text color to white.
;In order to do this, we won't be accessing the DXF attributes of the dimstyles
;using entget+entmod because of problems with <dimstyle overrides>.
;We will loop through each dimstyle, set it to the current dimstyle using
;AutoCAD's "DIMSTYLE" command, then set its DIMCLRT value to white (i.e:7)
;then save the current dimstyle back to the same name.
(setq dimStyleIdentifier (cdr (assoc 2 (tblnext "DIMSTYLE" T)))) ;get the first DIMSTYLE name and store it in dimStyleIdentifier
; the cdr(assoc 2 (...)) is necessary, because (tblnext "DIMSTYLE) returns a big list which is the DXF
;definition of the dimstyle. So we have to extract only its name. The DXF code for the name is #2.
(while dimStyleIdentifier
(command "._DIMSTYLE" "R" (cdr (assoc 2 dimStyleIdentifier))) ;invoke the "DIMSTYLE" autoCAD command
;and set the current dimstyle to be dimStyleIdentifier
(setvar "dimclrt" 7) ;set the DIMCLRT value to 7, i.e: text color to white
(command "._DIMSTYLE" "save" (cdr (assoc 2 dimStyleIdentifier)) "Y"); save the dimstyle
(setq dimStyleIdentifier (cdr (assoc 2 (tblnext "DIMSTYLE" T)))) ;get the next dimstyle
) ;ends the while loop
) ;end the defun
If you think there is a cleaner way to do things, please give me a shout. It's by learning from the pros that we get better!
That's cool, now I learned how to use DXF manipulation, using AutoCAD commands, what else do I need? Learn the commands reference guide better?
It's bed time for me, see you soon :kewl:
EDIT: later this week, I will code a text translator for changing text that is on the drawing, let's see if I can get it right the first time :pissed: