Crank,
Could you walk me through alittle bit more on your idea? Not following it totally.
Here's an example of very basic code that may help you:
; https://www.theswamp.org/index.php?topic=53489.0
(defun c:DimDef18 () (MakeDstyle "CROC" 1.8))
(defun c:DimDef25 () (MakeDstyle "CROC" 2.5))
(defun c:DimDef35 () (MakeDstyle "CROC" 3.5))
(defun MakeDstyle (dimname th / ts)
;********************************************** Variables for parent:
(if (not (tblsearch "STYLE" "SWAMP"))(progn
(setq ts (getvar "TEXTSTYLE"))
(command-s ".-style" "SWAMP" "romanc.shx" "A" "y" "n" "" "1.0" "0.0" "N" "N" "N")
(setvar "TEXTSTYLE" ts)
))
(setvar "DIMARCSYM" 0) (setvar "DIMADEC" 0) (setvar "DIMALT" 0) (setvar "DIMALTD" 2) (setvar "DIMALTF" (/ 1.0 25.4))
(setvar "DIMALTRND" 0.0)(setvar "DIMALTTD" 2) (setvar "DIMALTTZ" 0) (setvar "DIMALTU" 8)
(setvar "DIMALTZ" 0) (setvar "DIMAPOST" ".") (setvar "DIMASSOC" 2)
(setvar "DIMASZ" 2.5) (setvar "DIMATFIT" 0) (setvar "DIMAUNIT" 0) (setvar "DIMAZIN" 2)
(setvar "DIMBLK" ".") (setvar "DIMBLK1" ".") (setvar "DIMBLK2" ".") (setvar "DIMCEN" 2.0)
(setvar "DIMCLRD" 0) (setvar "DIMCLRE" 0) (setvar "DIMCLRT" 2) (setvar "DIMDEC" 3)
(setvar "DIMDLE" 0.0) (setvar "DIMDLI" (fix (* th 2.86))) (setvar "DIMDSEP" ",") (setvar "DIMEXE" 1.0)
(setvar "DIMEXO" 3.0) (setvar "DIMFIT" 4) (setvar "DIMFRAC" 0) (setvar "DIMGAP" (* 0.2 th))
(setvar "DIMJOGANG" (dtr 60))(setvar "DIMJUST" 0) (setvar "DIMLDRBLK" ".")(setvar "DIMLFAC" 1.00)
(setvar "DIMLIM" 0) (setvar "DIMLTEX1" "BYBLOCK") (setvar "DIMLTEX2" "BYBLOCK") (setvar "DIMLTYPE" "BYBLOCK")
(setvar "DIMLUNIT" 2) (setvar "DIMLWD" -2) (setvar "DIMLWE" -2) (setvar "DIMPOST" ".")
(setvar "DIMRND" 0.000) (setvar "DIMSAH" 0) (setvar "DIMSD1" 0) (setvar "DIMSD2" 0)
(setvar "DIMSCALE" 0) (setvar "DIMSE1" 0) (setvar "DIMSE2" 0) (setvar "DIMSOXD" 0)
(setvar "DIMTAD" 1) (setvar "DIMTDEC" 3) (setvar "DIMTFAC" 1.0) (setvar "DIMTFILL" 0) (setvar "DIMTFILLCLR" 0)
(setvar "DIMTIH" 0) (setvar "DIMTIX" 1) (setvar "DIMTM" 0.0) (setvar "DIMTMOVE" 1) (setvar "DIMTOFL" 1)
(setvar "DIMTOH" 0) (setvar "DIMTOL" 0) (setvar "DIMTOLJ" 1) (setvar "DIMTP" 0.0)
(setvar "DIMTSZ" 0.0) (setvar "DIMTVP" 0.0) (setvar "DIMTXSTY" "SWAMP")(setvar "DIMTXT" 2.5)
(setvar "DIMTZIN" 0) (setvar "DIMUPT" 0) (setvar "DIMZIN" 8)
;********************************************** Settings for textheigth:
(setvar "DIMTXT" th)(setvar "DIMCLRT" (fix th))
(setq dimname (strcat dimname (rtos (* th 10))))
;********************************************** Make sure the parent dimstyle exists:
(if (not (tblsearch "DIMSTYLE" dimname))
(savedimstyle dimname "")
)
;********************************************** Substyles with overrides:
; lineair
(make_SWAMPTICK); create block
(setvar "DIMBLK" "SWAMPTICK")
(if (< th 2)(setvar "DIMASZ" 0.7)(setvar "DIMASZ" 1.0))
(savedimstyle dimname "$0")
; angular
(setvar "DIMDEC" 0)
(setvar "DIMADEC" 2)
(setvar "DIMATFIT" 1)
(setvar "DIMTMOVE" 2)
(setvar "DIMTIX" 0)
(setvar "DIMTIH" 1)
(setvar "DIMTOH" 1)
(savedimstyle dimname "$2")
; diameter
(setvar "DIMATFIT" 2)
(setvar "DIMTMOVE" 0)
(setvar "DIMTIX" 0)
(savedimstyle dimname "$3")
; radial
(setvar "DIMATFIT" 2)
(setvar "DIMTMOVE" 0)
(setvar "DIMTIX" 0)
(setvar "DIMPOST" "r=<>")
(savedimstyle dimname "$4")
; coords
; (setvar )
(savedimstyle dimname "$6")
; leader
; (setvar )
(savedimstyle dimname "$7")
(princ)
)
(defun savedimstyle (parent sub / )
(setq name (strcat parent sub))
(if (tblsearch "DIMSTYLE" name)
(command-s ".-dimstyle" "ANnotative" "yes" name "YES" "SAVE" name "YES")
(command-s ".-dimstyle" "ANnotative" "yes" name "SAVE" name "YES")
)
(command-s ".dim1" "restore" parent); Restore Parent dimstyle <<<<<<<<<<<
)
(defun dtr ( deg ) (* pi (/ deg 180.0)))
(defun make_SWAMPTICK ()
(setvar "NOMUTT" 1)
(entmake '((0 . "BLOCK") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockReference") (2 . "SWAMPTICK") (10 0 0 0) (70 . 0)))
(entmake '((0 . "LINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (62 . 0) (6 . "ByBlock") (100 . "AcDbLine") (10 0 -2 0) (11 0 2 0)))
(entmake '((0 . "LINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (62 . 0) (6 . "ByBlock") (100 . "AcDbLine") (10 -2 0 0) (11 2 0 0)))
(entmake '((0 . "LINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (62 . 2) (6 . "ByBlock") (100 . "AcDbLine") (10 -1 -1 0) (11 1 1 0)))
(entmake '((0 . "ENDBLK")(100 . "AcDbBlockEnd") (8 . "0")))
(setvar "NOMUTT" 0)
)
(princ)
First a parent dimstyle is created and current.
If you need a substyle, then change some dim variables. At this point you have a parent dimstyle with overrides.
Save these dim variables to a new dimstyle with the proper name for the substyle.
Repeat this for every substyle and be sure the parent style is current again.
So basicly all you have to do is change a variable and then save the dimstyle.
Nb.: Your varibles will be different. Use the following command to find the settings of your dimstyle:
SETVAR ?
DIM*