Dim Style Lisp help - where to start
I'm looking for a LISP that will reset or set (depending on your point of view) ALL of the Dim Styles in a drawing so that their:
- Dimension Lines Color is BY LAYER
- Extension Lines Color is BY LAYER
- Text Appearance/Text Color is BY LAYER
The main reason I would need this is that we use different architect's drawings as Xref's. I go into the target drawing and change the Xrefs Layers to one color so our products stand out from their backgrounds. But since the Dims are not set BY LAYER they show in their normal setting and interfere with our product details.
I have a LISP that changes their drawings to Color By Layer but it leaves the Dims alone.
Any ideas?
Re: Dim Style Lisp help - where to start
Quote:
Originally Posted by
gfreddog
I'm looking for a LISP that will reset or set (depending on your point of view) ALL of the Dim Styles in a drawing so that their:
- Dimension Lines Color is BY LAYER
- Extension Lines Color is BY LAYER
- Text Appearance/Text Color is BY LAYER
The main reason I would need this is that we use different architect's drawings as Xref's. I go into the target drawing and change the Xrefs Layers to one color so our products stand out from their backgrounds. But since the Dims are not set BY LAYER they show in their normal setting and interfere with our product details.
I have a LISP that changes their drawings to Color By Layer but it leaves the Dims alone.
Any ideas?
My idea (although it might not be a very good one) is to write a little routine that will recreate a dimensions style. This would in effect reset all current dimensions, however, the existing dimensions may still need to be updated using the update dimension command. based on my limited testing in 09, the existing dimensions are updated automatically when the dimension style is changed, including scale factors.
here is the code I am using, you will have to substitute the settings you wish to use for the settings we use. The current program is designed to have a scale pushed through as an argument from one of our other programs, you can eliminate it, or force the user to specify the scale. The program is using dimassoc set to 1 which is why we push the scale to the dimension style.
Code:
(defun vcurvedim (vcurvescale / dstylename)
(command "-style" "DIM" "Simplex.shx" 0 1 0 "" "" "")
(setvar "DIMADEC" 2) ;Angular decimal places
(command "DIMALT" "Off") ;Alternate units selected
(setvar "DIMALTD" 2) ;Alternate unit decimal places
(setvar "DIMALTF" 25.4000) ;Alternate unit scale factor
(setvar "DIMALTRND" 0.0000) ;Alternate units rounding value
(setvar "DIMALTTD" 2) ;Alternate tolerance decimal places
(setvar "DIMALTTZ" 0) ;Alternate tolerance zero suppression
(setvar "DIMALTU" 2) ;Alternate units
(setvar "DIMALTZ" 0) ;Alternate unit zero suppression
(setvar "DIMAPOST" "") ;Prefix and suffix for alternate text
(setvar "DIMARCSYM" 0) ;Arc length symbol
(setvar "DIMASZ" 0.1500) ;Arrow size
(setvar "DIMATFIT" 3) ;Arrow and text fit
(setvar "DIMAUNIT" 1) ;Angular unit format
(setvar "DIMAZIN" 3) ;Angular zero supression
(setvar "DIMBLK" "Oblique") ;Arrow block name
(command "DIMBLK1" ".") ;First arrow block name
(command "DIMBLK2" ".") ;Second arrow block name
(setvar "DIMCEN" 0.0900) ;Center mark size
(setvar "DIMCLRD" 256) ;Dimension line and leader color
(setvar "DIMCLRE" 256) ;Extension line color
(setvar "DIMCLRT" 256) ;Dimension text color
(setvar "DIMDEC" 3) ;Decimal places
(setvar "DIMDLE" 0.0750) ;Dimension line extension
(setvar "DIMDLI" 0.3800) ;Dimension line spacing
(setvar "DIMDSEP" ".") ;Decimal separator
(setvar "DIMEXE" 0.0750) ;Extension above dimension line
(setvar "DIMEXO" 0.0625) ;Extension line origin offset
(setvar "DIMFRAC" 2) ;Fraction format
(setvar "DIMFXL" 1.0000) ;Fixed Extension Line
(command "DIMFXLON" "Off") ;Enable Fixed Extension Line
(setvar "DIMGAP" 0.0400) ;Gap from dimension line to text
(command "DIMJOGANG" 45) ;Radius dimension jog angle
(setvar "DIMJUST" 0) ;Justification of text on dimension line
(command "DIMLDRBLK" ".") ;Leader block name
(setvar "DIMLFAC" vcurvescale) ;Linear unit scale factor
(command "DIMLIM" "Off") ;Generate dimension limits
(command "DIMLTEX1" "") ;Linetype extension line 1
(command "DIMLTEX2" "") ;Linetype extension line 2
(command "DIMLTYPE" "") ;Dimension linetype
(setvar "DIMLUNIT" 2) ;Linear unit format
(setvar "DIMLWD" -2) ;Dimension line and leader lineweight
(setvar "DIMLWE" -2) ;Extension line lineweight
(setvar "DIMPOST" "'") ;Prefix and suffix for dimension text
(setvar "DIMRND" 0.0000) ;Rounding value
(command "DIMSAH" "Off") ;Separate arrow blocks
(setvar "DIMSCALE" 1.0000) ;Overall scale factor
(command "DIMSD1" "Off") ;Suppress the first dimension line
(command "DIMSD2" "Off") ;Suppress the second dimension line
(command "DIMSE1" "On") ;Suppress the first extension line
(command "DIMSE2" "On") ;Suppress the second extension line
(command "DIMSOXD" "Off") ;Suppress outside dimension lines
(setvar "DIMTAD" 1) ;Place text above the dimension line
(setvar "DIMTDEC" 3) ;Tolerance decimal places
(setvar "DIMTFAC" 1.0000) ;Tolerance text height scaling factor
(setvar "DIMTFILL" 1) ;Text background enabled
(setvar "DIMTFILLCLR" 0) ;Text background color
(command "DIMTIH" "Off") ;Text inside extensions is horizontal
(command "DIMTIX" "On") ;Place text inside extensions
(setvar "DIMTM" 0.0000) ;Minus tolerance
(setvar "DIMTMOVE" 2) ;Text movement
(command "DIMTOFL" "On") ;Force line inside extension lines
(command "DIMTOH" "Off") ;Text outside horizontal
(command "DIMTOL" "Off") ;Tolerance dimensioning
(setvar "DIMTOLJ" 1) ;Tolerance vertical justification
(setvar "DIMTP" 0.0000) ;Plus tolerance
(setvar "DIMTSZ" 0.0000) ;Tick size
(setvar "DIMTVP" 0.0000) ;Text vertical position
(setvar "DIMTXSTY" "DIM") ;Text style
(setvar "DIMTXT" 0.0800) ;Text height
(setvar "DIMTZIN" 0) ;Tolerance zero suppression
(command "DIMUPT" "Off") ;User positioned text
(setvar "DIMZIN" 12) ;Zero suppression
(setq dstylename "ENGLISHVC")
(command "dimstyle"
"save"
dstylename
) ;_ end of command
) ;_ end of defun
Re: Dim Style Lisp help - where to start
could you select or isolate only the dimensions then run the setbylayer command?
Re: Dim Style Lisp help - where to start
It doesnt work because it isnt the dimension that is not by layer, it is the elements inside the dimension that are not bylayer. As an example, our dimension layer is green, but when we put in a dimension it is blue, setbylayer doesnt turn it green.
Re: Dim Style Lisp help - where to start
Quote:
Originally Posted by
ccowgill
It doesnt work because it isnt the dimension that is not by layer, it is the elements inside the dimension that are not bylayer. As an example, our dimension layer is green, but when we put in a dimension it is blue, setbylayer doesnt turn it green.
I see, just tossing out suggestions as I attempt to learn lisp
Re: Dim Style Lisp help - where to start
Quote:
Originally Posted by
ccowgill
My idea (although it might not be a very good one) is to write a little routine that will recreate a dimensions style. This would in effect reset all current dimensions, however, the existing dimensions may still need to be updated using the update dimension command. based on my limited testing in 09, the existing dimensions are updated automatically when the dimension style is changed, including scale factors.
Hmmm I was thinking this was going to be a project and looks like it will be darn 8)
Ccowgill, thanks for the starting point. I'm going to use your idea and see how it goes.
Thanks for the help
Re: Dim Style Lisp help - where to start
I couldn't think of a good function name, but this should work.
Code:
(defun c:DSCBL (/ DimStyles@ StyleName$)
(princ "\nDimstyles color bylayer")
(setq StyleName$ (cdr (assoc 2 (tblnext "DIMSTYLE" t))))
(setq DimStyles@ (list StyleName$))
(while (setq StyleName$ (cdr (assoc 2 (tblnext "DIMSTYLE"))))
(setq DimStyles@ (append DimStyles@ (list StyleName$)))
);while
(foreach StyleName$ DimStyles@
(command "DIMSTYLE" "R" StyleName$)
(setvar "DIMCLRD" 256);Dimension line and leader color
(setvar "DIMCLRE" 256);Extension line color
(setvar "DIMCLRT" 256);Dimension text color
(command "DIMSTYLE" "S" StyleName$ "Y")
);foreach
(princ)
);defun
Re: Dim Style Lisp help - where to start
Quote:
Originally Posted by
Terry Cadd
I couldn't think of a good function name, but this should work.
Code:
(defun c:DSCBL (/ DimStyles@ StyleName$)
(princ "\nDimstyles color bylayer")
(setq StyleName$ (cdr (assoc 2 (tblnext "DIMSTYLE" t))))
(setq DimStyles@ (list StyleName$))
(while (setq StyleName$ (cdr (assoc 2 (tblnext "DIMSTYLE"))))
(setq DimStyles@ (append DimStyles@ (list StyleName$)))
);while
(foreach StyleName$ DimStyles@
(command "DIMSTYLE" "R" StyleName$)
(setvar "DIMCLRD" 256);Dimension line and leader color
(setvar "DIMCLRE" 256);Extension line color
(setvar "DIMCLRT" 256);Dimension text color
(command "DIMSTYLE" "S" StyleName$ "Y")
);foreach
(princ)
);defun
Egads that works too!
I called it DCBL (Dims Color By Layer)
Thanks everyone for the help AGAIN!
Have I told you all lately that AUGI Rocks? Well it does!
Re: Dim Style Lisp help - where to start
Quote:
Originally Posted by
Terry Cadd
I couldn't think of a good function name, but this should work.
Code:
(defun c:DSCBL (/ DimStyles@ StyleName$)
(princ "\nDimstyles color bylayer")
(setq StyleName$ (cdr (assoc 2 (tblnext "DIMSTYLE" t))))
(setq DimStyles@ (list StyleName$))
(while (setq StyleName$ (cdr (assoc 2 (tblnext "DIMSTYLE"))))
(setq DimStyles@ (append DimStyles@ (list StyleName$)))
);while
(foreach StyleName$ DimStyles@
(command "DIMSTYLE" "R" StyleName$)
(setvar "DIMCLRD" 256);Dimension line and leader color
(setvar "DIMCLRE" 256);Extension line color
(setvar "DIMCLRT" 256);Dimension text color
(command "DIMSTYLE" "S" StyleName$ "Y")
);foreach
(princ)
);defun
Thanks Terry CADD, that was just what I needed.
I was having a hard time figuring out how to build the dimstyle list to iterate through them.
Had not seen tblnext before.