Jump to content

match Dimension property


Andi

Recommended Posts

I am looking for lisp code which can change the dimension properties. Color to Red, Arrow size to 0.60 and Text height to 0.50
Please help. Thank you. 

Link to comment
Share on other sites

Modified from here to add arrow size and text height

https://www.cadtutor.net/forum/topic/75686-please-help-me-create-a-lisp-to-change-color-of-dimension/?do=findComment&comment=598520

 

;; Tharwat Al Choufi ;;
;; website: https://autolispprograms.wordpress.com	;;
(defun c:Test (/ ss ent obj)
  (if (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))
    (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq obj (vlax-ename->vla-object ent))
      (vla-put-Color obj 1)
      (vla-put-TextColor obj 1)
      (vla-put-ExtensionLineColor obj 1)
      (vla-put-DimensionLineColor obj 1)
      (vla-put-arrowheadsize obj 0.60)
      (vla-put-textheight obj 0.50)
    )
  )
  (princ)
)

 

 

  • Like 1
Link to comment
Share on other sites

Thank you for your help.

 

If I want to add some more properties like fractional type, Unit type, etc. Then can you please guide me how to add. I tried like below. But it is not working.

 

(defun c:Test (/ ss ent obj)
  (if (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))
    (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq obj (vlax-ename->vla-object ent))
      (vla-put-Color obj 1)
      (vla-put-TextColor obj 1)
      (vla-put-ExtensionLineColor obj 1)
      (vla-put-DimensionLineColor obj 1)
      (vla-put-arrowheadsize obj 0.60)
      (vla-put-textheight obj 0.50)
      (vla-put-FractionalType obj NotStacked)
      (vla-put-DimUnits obj Fractional)
    )
  )
  (princ)
)

 

Link to comment
Share on other sites

Not sure if this will work, but at least you'll need to put string values in double quotes. 

 

(vla-put-FractionalType obj "NotStacked")

(vla-put-DimUnits obj "Fractional")

Link to comment
Share on other sites

In the menus they have the text call outs,  but the variables usually use numbers for different settings/mode like rtos

 

(defun c:Test (/ ss ent obj)
  (if (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))
    (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq obj (vlax-ename->vla-object ent))
      (vla-put-Color obj 1)
      (vla-put-TextColor obj 1)
      (vla-put-ExtensionLineColor obj 1)
      (vla-put-DimensionLineColor obj 1)
      (vla-put-arrowheadsize obj 0.60)
      (vla-put-textheight obj 0.50)
      (vla-put-FractionFormat obj 2)
      (vla-put-UnitsFormat obj 5)
    )
  )
  (princ)
)

 

I don't know all the settings but use this to figure them out. Change the settings to what you want and then dump the properties.

 

;;----------------------------------------------------------------------------;;
;; Dump all methods and properties for selected objects               
(defun C:VDumpIt (/ ent)
  (while (setq ent (car (entsel "\nSelect Entity to Dump")))
    (vlax-Dump-Object (vlax-Ename->Vla-Object ent) t)
  )
  (textscr)
  (princ)
)

 

if its listed it usually has a vla-put-"property"

Edited by mhupp
Link to comment
Share on other sites

16 hours ago, mhupp said:
(defun c:Test (/ ss ent obj)
  (if (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))
    (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq obj (vlax-ename->vla-object ent))
      (vla-put-Color obj 1)
      (vla-put-TextColor obj 1)
      (vla-put-ExtensionLineColor obj 1)
      (vla-put-DimensionLineColor obj 1)
      (vla-put-arrowheadsize obj 0.60)
      (vla-put-textheight obj 0.50)
      (vla-put-FractionFormat obj 2)
      (vla-put-UnitsFormat obj 5)
    )
  )
  (princ)
)

Thanks a lot....its working. So instead of text we have to give number as what is in option list.  I don't understand what you are saying about dump the properties. What exactly it is doing? Once again Thanks!!!

Link to comment
Share on other sites

5 hours ago, Andi said:

Thanks a lot....its working. So instead of text we have to give number as what is in option list.  I don't understand what you are saying about dump the properties. What exactly it is doing? Once again Thanks!!!

 

  1. Yes, that is how most variables work and you either have to remember what the numbers mean, look them up, or use the dump to see what current settings are.
  2. I used vdump on a dimension and this are all the current properties you can change (unless they are locked has RO - read only). As you can see most use numbers.

So lets say you wanted to show the alternate units in the dims. Currently its set to 0 or off

(vla-put-AltUnits obj 1) ;turns alt units on
(vla-put-TextSuffix obj "mm") ;adds mm to the end of alt units

 

; IAcadDimRotated 2798f900 : TeighaX Interface of a dimension that measures the distance between two points and is displayed at a given rotation
;
; Property values :
;
;   AltRoundDistance = 0.0
;   AltSubUnitsFactor = NIL
;   AltSubUnitsSuffix = NIL
;   AltSuppressLeadingZeros = 0
;   AltSuppressTrailingZeros = 0
;   AltSuppressZeroFeet = -1
;   AltSuppressZeroInches = -1
;   AltTextPrefix = ""
;   AltTextSuffix = ""
;   AltTolerancePrecision = 2
;   AltToleranceSuppressLeadingZeros = 0
;   AltToleranceSuppressTrailingZeros = 0
;   AltToleranceSuppressZeroFeet = -1
;   AltToleranceSuppressZeroInches = -1
;   AltUnits = 0
;   AltUnitsFormat = 2
;   AltUnitsPrecision = 2
;   AltUnitsScale = 25.4
;   Application (RO) = #<VLA-OBJECT IAcadApplication 0000000027634DF0>
;   Arrowhead1Block = ""
;   Arrowhead1Type = 0
;   Arrowhead2Block = ""
;   Arrowhead2Type = 0
;   ArrowheadSize = 0.35
;   color = 256
;   Database (RO) = #<VLA-OBJECT IAcadDatabase 0000000027DF9408>
;   DecimalSeparator = "."
;   DimConstrDesc = NIL
;   DimConstrExpression = NIL
;   DimConstrForm = NIL
;   DimConstrName = NIL
;   DimConstrReference = NIL
;   DimConstrValue = NIL
;   DimensionLineColor = 0
;   DimensionLineExtend = 0.0
;   DimensionLinetype = ""
;   DimensionLineWeight = -2
;   DimLine1Suppress = 0
;   DimLine2Suppress = 0
;   DimLineInside = 0
;   Document (RO) = #<VLA-OBJECT IAcadDocument 0000000027D8C468>
;   EntityName (RO) = "AcDbRotatedDimension"
;   EntityType (RO) = NIL
;   ExtensionLineColor = 0
;   ExtensionLineExtend = 0.125
;   ExtensionLineOffset = 0.125
;   ExtensionLineWeight = -2
;   ExtLine1Linetype = ""
;   ExtLine1Suppress = 0
;   ExtLine2Linetype = ""
;   ExtLine2Suppress = 0
;   ExtLineFixedLen = 1.0
;   ExtLineFixedLenSuppress = 0
;   Fit = 3
;   ForceLineInside = 0
;   FractionFormat = 0
;   Handle (RO) = "20702"
;   HasExtensionDictionary (RO) = 0
;   HorizontalTextPosition = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0000000052DECB38>
;   Layer = "0"
;   LinearScaleFactor = 1.0
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Measurement (RO) = 45.7393393773118
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 668216432
;   ObjectID32 (RO) = 668216432
;   ObjectName (RO) = "AcDbRotatedDimension"
;   OwnerID (RO) = 668922848
;   OwnerID32 (RO) = 668922848
;   PlotStyleName = "ByLayer"
;   PrimaryUnitsPrecision = 3
;   Rotation = 0.0
;   RoundDistance = 0.0
;   ScaleFactor = 1.0
;   StyleName = "Standard"
;   SubUnitsFactor = NIL
;   SubUnitsSuffix = NIL
;   SuppressLeadingZeros = 0
;   SuppressTrailingZeros = 0
;   SuppressZeroFeet = -1
;   SuppressZeroInches = -1
;   TextColor = 0
;   TextFill = 0
;   TextFillColor = 0
;   TextGap = 0.25
;   TextHeight = 0.35
;   TextInside = 0
;   TextInsideAlign = 0
;   TextMovement = 0
;   TextOutsideAlign = -1
;   TextOverride = ""
;   TextPosition = (59.5822222174528 27.7485201652591 0.0)
;   TextPrefix = ""
;   TextRotation = 0.0
;   TextStyle = "Standard"
;   TextSuffix = "\""
;   ToleranceDisplay = 0
;   ToleranceHeightScale = 1.0
;   ToleranceJustification = 1
;   ToleranceLowerLimit = 0.0
;   TolerancePrecision = 3
;   ToleranceSuppressLeadingZeros = 0
;   ToleranceSuppressTrailingZeros = 0
;   ToleranceSuppressZeroFeet = -1
;   ToleranceSuppressZeroInches = -1
;   ToleranceUpperLimit = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 0000000052F064F8>
;   UnitsFormat = 2
;   VerticalTextPosition = 0
;   Visible = -1
;
; Methods supported :
;
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   Copy ()
;   Delete ()
;   Erase ()
;   GetBoundingBox (2)
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()

 

Edited by mhupp
  • Like 1
Link to comment
Share on other sites

Like mhupp a bit more detail not sure where I got this it is part code of a entmake a dim. Uses dxf number rather than VL name. So would use entmod method for your request 

 

	       (CONS 0 "DIMSTYLE")								    ;Entity Type
	       (CONS 100 "AcDbSymbolTableRecord")						    ;Subclass marker
	       (CONS 100 "AcDbDimStyleTableRecord")						    ;Subclass marker
	       (CONS 2 xname$)									    ;Dimstyle name
	       (CONS 70 0)									    ;Standard flag value
	       (CONS 3 "")									    ;DIMPOST   - Prefix and suffix for dimension text
	       (CONS 4 "")									    ;DIMAPOST  - Prefix and suffix for alternate text
	       ;;(CONS 5 "ARR1")   -DXF CODES OBSOLETE					    ;DIMBLK    - Arrow block name
	       ;;(CONS 6 "ARR1")   -DXF CODES OBSOLETE					    ;DIMBLK1   - First arrow block name
	       ;;(CONS 7 "")         -DXF CODES OBSOLETE					    ;DIMBLK2   - Second arrow block name
	       (CONS 40 100.0)									    ;DIMSCALE  - Overall Scale Factor
	       (CONS 41 1.0)									    ;DIMASZ    - Arrow size
	       (CONS 42 2.0)									    ;DIMEXO    - Extension line origin offset
	       (CONS 43 0.0)									    ;DIMDLI    - Dimension line spacing
	       (CONS 44 2.0)									    ;DIMEXE    - Extension above dimension line
	       (CONS 45 0.0)									    ;DIMRND    - Rounding value
	       (CONS 46 0.0)									    ;DIMDLE    - Dimension line extension
	       (CONS 47 0.0)									    ;DIMTP     - Plus tolerance
	       (CONS 48 0.0)									    ;DIMTM     - Minus tolerance
	       (CONS 140 xheight$)							    ;DIMTXT    - Text height
	       (CONS 141 0.09)								    ;DIMCEN    - Centre mark size
	       (CONS 142 0.0)									    ;DIMTSZ    - Tick size
	       (CONS 143 25.4)								    ;DIMALTF   - Alternate unit scale factor
	       (CONS 144 1.0)									    ;DIMLFAC   - Linear unit scale factor
	       (CONS 145 0.0)									    ;DIMTVP    - Text vertical position
	       (CONS 146 1.0)									    ;DIMTFAC   - Tolerance text height scaling factor
	       (CONS 147 1.0)									    ;DIMGAP    - Gape from dimension line to text
	       (CONS 71 0)									    ;DIMTOL    - Tolerance dimensioning
	       (CONS 72 0)									    ;DIMLIM    - Generate dimension limits
	       (CONS 73 0)									    ;DIMTIH    - Text inside extensions is horizontal
	       (CONS 74 0)									    ;DIMTOH    - Text outside horizontal
	       (CONS 75 0)									    ;DIMSE1    - Suppress the first extension line
	       (CONS 76 0)									    ;DIMSE2    - Suppress the second extension line
	       (CONS 77 1)									    ;DIMTAD    - Place text above the dimension line
	       (CONS 78 0)									    ;DIMZIN    - Zero suppression
	       (CONS 170 0)									    ;DIMALT    - Alternate units selected
	       (CONS 171 2)									    ;DIMALTD   - Alternate unit decimal places
	       (CONS 172 0)									    ;DIMTOFL   - Force line inside extension lines
	       (CONS 173 0)									    ;DIMSAH    - Separate arrow blocks
	       (CONS 174 0)									    ;DIMTIX    - Place text inside extensions
	       (CONS 175 0)									    ;DIMSOXD   - Suppress outside dimension lines
	       (CONS 176 1)									    ;DIMCLRD   - Dimension line and leader color
	       (CONS 177 1)									    ;DIMCLRE   - Extension line color
	       (CONS 178 xcolor$)								    ;DIMCRRT   - Dimension text color
	       (CONS 270 2)									    ;DIMUNIT (Obsolete in 2011, DIMLUNIT and DIMFRAC)
	       (CONS 271 0)									    ;DIMADEC   - Angular decimal places
	       (CONS 272 0)									    ;DIMTDEC   - Tolerance decimal places
	       (CONS 273 2)									    ;DIMALTU   - Alternate units
	       (CONS 274 2)									    ;DIMALTTD  - Alternate tolerance decimal places
	       (CONS 275 0)									    ;DIMAUNIT  - Angular unit format
	       (CONS 280 0)									    ;DIMJUST   - Justification of text on dimension line
	       (CONS 281 0)									    ;DIMSD1    - Suppress the first dimension line
	       (CONS 282 0)									    ;DIMSD2    - Suppress the second dimensions line
	       (CONS 283 1)									    ;DIMTOLJ   - Tolerance vertical justification
	       (CONS 284 0)									    ;DIMTZIN   - Zero suppression
	       (CONS 285 0)									    ;DIMALTZ   - Alternate unit zero suppression
	       (CONS 286 0)									    ;DIMALTTZ  - Alternate tolerance zero suppression
	       (CONS 287 5)									    ;DIMFIT (Obsolete in 2011, DIMATFIT and DIMTMOVE)
	       (CONS 288 1)									    ;DIMUPT    - User positioned text
	       (CONS 340 (TBLOBJNAME "STYLE" xstyle$))						    ;DIMTXSTY  - Text style
	       (CONS 341
		     (CDR (ASSOC 330 (ENTGET (TBLOBJNAME "BLOCK" xstyle$))))
	       )										    ;DIMLDRBLK - Leader arrow block name
	       (CONS 342
		     (CDR (ASSOC 330 (ENTGET (TBLOBJNAME "BLOCK" xstyle$))))
	       )										    ;DIMBLK    - Arrow block name
	       (CONS 343
		     (CDR (ASSOC 330 (ENTGET (TBLOBJNAME "BLOCK" xstyle$))))
	       )										    ;DIMBLK1   - First arrow block name
	       (CONS 344
		     (CDR (ASSOC 330 (ENTGET (TBLOBJNAME "BLOCK" xstyle$))))
	       )										    ;DIMBLK2   - Second arrow block name
	     )											    ;End of list

 

 

Edited by BIGAL
  • Like 2
Link to comment
Share on other sites

Dimension overrides are messy and are lost when the drawing they're in are inserted into another drawing.

 

A cleaner way might be to select a dimension you want modified, modify it in the Properties Palette, then right-click and select  Dim Style → Save as New Dim Style… giving it a descriptive name like "Red→0.6 h0.5"

Then just change any other dimensions to that Dim Style you want. Next time you need it just import that Dim Style or add it to any templates that Dim Style would be useful in.

  • Like 3
Link to comment
Share on other sites

  • 1 month later...

I tried this dimension style import export process. But the issue is for every drawing I need to import the dimension style .dim file and then need to select that dimension style. In a day I need to work on around 30 to 40 drawings. So is there any way to call that .dim file and set as dimension file automatically? I have attached my .dim file.

Dimprp.dim

Link to comment
Share on other sites

25 minutes ago, Andi said:

I tried this dimension style import export process. But the issue is for every drawing I need to import the dimension style .dim file and then need to select that dimension style. In a day I need to work on around 30 to 40 drawings. So is there any way to call that .dim file and set as dimension file automatically? I have attached my .dim file.

Dimprp.dim 1.79 kB · 0 downloads

I use macros to quickly import dimension styles from another template or drawing file using Lee Mac's Steal From Drawing lisp. The code could just as easily be added to acaddoc.lsp to run every time a drawing is opened if that's how you prefer.

 

If you reply with the path and name of a dwt or dwg file with a list of dimension styles and anything Lee shows can be imported with the lisp I'll write the macro or code for you if you want.

I use that lisp for everything. Thanks Lee!

Link to comment
Share on other sites

You could try this:

https://stackoverflow.com/questions/47835301/use-autolisp-to-generate-new-dimension-style

 

Will set a dimension style, run either as required or whenever a drawing opens.

You might need to check that the dimension style exists in the drawing first or create it:

 

(defun tablesearch ( s / d r) ;;List Dimstyles
  (while (setq d (tblnext s (null d)))
    (setq r (cons (cdr (assoc 2 d)) r))
  )
)


(princ "Exsting DIM styles: ")(princ (tableSearch "dimstyle"))

 

I think you can change the last lines to something like this, where DimStyleName is the dim style name you want to use

 

  (if (= (member DimStyleName (tableSearch "dimstyle")) nil)
    (command "dimstyle" "s" DimStyleName)
    (command "dimstyle" "s" DimStyleName "Y")
  )

 

You might also need to check that your font is loaded or exists

 

(mytextstyle FontName)


(defun mytextstyle ( myfont / mytextstyle fontcount fontlist) ;;check textstyle is loaded
;;Font Style Lists - standard ones I use
;;Fontname Height WidthFactor ObliqueAngle Backwards UpsideDown
  (setq fontstyles (list
    (list "Standard" "Arial" "0.0000" "1.0000" "0" "No" "No")
    (list "romans" "romans.shx" "0.0000" "1.0000" "0" "No" "No")
    (list "CompantyArial" "Arial" "0.0000" "1.0000" "0" "No" "No")
  ));end fontstyles list

 (if (member myfont (tableSearch "style"))
  (princ "Font Is Loaded")
  (progn ;' font isn't loaded
    (setq fontcount 0)
    (while (< fontcount (length fontstyles))
      (if (= (strcase (nth 0 (nth fontcount fontstyles))) (strcase myfont))
        (progn ;font style is loaded
          (setq fontlist fontcount) ;;font style exists
        ) ; end progn
      ) ;end if
      (setq fontcount (+ 1 fontcount))
    )
  
    (if (= fontlist nil)
      (progn ;;if font is not defined above or loaded
        (alert "Font style needs loading. Please edit it")
        (command "Style" myfont "romans.shx" "0.0000" "1.0000" "0" "No" "No" "No")
        (initdia)
        (command "style")
      ) ;end progn
      (progn
        (command "style" (nth 0 (nth fontlist fontstyles)) (nth 1 (nth fontlist fontstyles))
                         (nth 2 (nth fontlist fontstyles)) (nth 3 (nth fontlist fontstyles))
                         (nth 4 (nth fontlist fontstyles)) (nth 5 (nth fontlist fontstyles))
                         (nth 6 (nth fontlist fontstyles)) (nth 7 (nth fontlist fontstyles))
        ) ;end command
      ) ;end progn
    ) ;end if
  ) ;end progn
  );end if
  (setq mystyle myfont) ;;text font style.. if anything else check if style is loaded into drawing here
  mystyle
);;End Sub Routines

 

and finally here is a list of all the vla- settings for dimension, copied and pasted from my version of 'jeff' above, the values are what I use and also the variable FontHeight since here I wanted things like arrow heads to be proportional to the text height, double and tripple ; are not used (;; and ;;;;)

 

 

; (setvar "DIMADEC"   0)    ;; 0              ;;Angular Dimension Decimal Places
;  (setvar "DIMALT"    0)    ;; 0              ;;Control of alternative units 0 - Off 1 - On
;  (setvar "DIMALTD"   3)    ;; 2 / 3          ;;Alternative Units Decimal Places
;  (setvar "DIMALTF" 0.0394) ;; 25.4 / 0.0394  ;;Alternative Units Scale Factor
;;(setvar "DIMALTMZF")      ;;                ;;Alternate sub-zero factor for metric dimensions - Unknown variable
;;(setvar "DIMALTMZS")      ;;                ;;Alternate sub-zero suffix for metric dimensions - Unknown variable
;  (setvar "DIMALTRND" 0.00) ;; 0.00           ;;Alternate units rounding value
;  (setvar "DIMALTTD"  3)    ;; 2 / 3          ;;Alternative Units Tolerance Decimal Places
;  (setvar "DIMALTTZ"  0)    ;; 0              ;;Alternate tolerance zero suppression
;  (setvar "DIMALTU"   2)    ;; 2              ;;Alternative Units Units
;  (setvar "DIMALTZ"   0)    ;; 0              ;;Alternate unit zero suppression
;  (setvar "DIMAPOST" "")    ;; ""             ;;Prefix and suffix for alternate text
;  (setvar "DIMARCSYM" 0)    ;; 0              ;;Arc Length Dimension Arc Symbol
  (setvar "DIMASZ" FontHeight) ;; 0.18 / 2.5  ;;Dimension Line and Leader Line Arrow Heads size
;  (setvar "DIMATFIT"  3)    ;; 3              ;;Arrow and text fit if distance is too narrow for both
;  (setvar "DIMAUNIT"  0)    ;; 0              ;;Angular unit format
;  (setvar "DIMAZIN"   0)    ;; 0              ;;Angular Dimension Depresses leading zeros
;  (setvar "DIMBLK"  ".")    ;; "."            ;;Arrow block name "." for closed flled else as properties
;  (setvar "DIMBLK1" ".")    ;; "."            ;;First arrow block name "." for closed flled else as properties
;  (setvar "DIMBLK2" ".")    ;; "."            ;;Second arrow block name "." for closed flled else as properties
  (setvar "DIMCEN" FontHeight) ;; 0.09 / 2.5  ;;Drawing centre mark for radius or diameter dimensions
  (setvar "DIMCLRD" LinCol) ;; 0              ;;Colours - Lines, ArrowHeads, Dimension Lines 0: ByLayer, 256 ByBlock
  (setvar "DIMCLRE" LinCol) ;; 0              ;;Colours - Extension Lines, Centre Marks Colours 0: ByLayer, 256 ByBlock
  (setvar "DIMCLRT" TxtCol) ;; 0              ;;Colours - Dimension Text Colour 0: ByLayer, 256 ByBlock
;  (setvar "DIMDEC"    3)    ;; 0              ;;Dimension Decimal Places
;  (setvar "DIMDLE"    0)    ;; 0.0000         ;;Dimension Line extension with oblique strokes instead of arrows
;  (setvar "DIMDLI"    4)    ;; 3.75           ;;Dimension Baseline Dimension Spacing
  (setvar "DIMDSEP" ".")    ;; .              ;;Decimal separator
  (setvar "DIMEXE" (/ Fontheight 2)) ;; 0.18 / 1.25    ;;Extension Line Extension distance
  (setvar "DIMEXO" (/ Fontheight 4)) ;; 0.0625 / 0.625 ;;Extension Line Offset
;  (setvar "DIMFRAC"   0)    ;; 0              ;;Dimension Fraction Format
;  (setvar "DIMFXL" 1.00)    ;; 1              ;;Fixed Extension Line
;  (setvar "DIMFXLON"  0)    ;; 0              ;;Enable Fixed Extension Line 0 - Off 1 - On
  (setvar "DIMGAP" (/ FontHeight 4)) ;; 0.09 / 0.625   ;;Dimension gap between text and arrow 
  (setvar "DIMJOGANG" (* pi (/ 45 180.0))) ;; ;;Radius dimension jog angle.. radians?
;  (setvar "DIMJUST"   0)    ;; 0              ;;Justification of text on dimension line
  (setvar "DIMLDRBLK" ".")  ;; "."            ;;Leader block name "." for closed flled else as properties
;  (setvar "DIMLFAC" 1.00)   ;; 1              ;;Linear unit scale factor
;  (setvar "DIMLIM"    0)    ;; 0              ;;Generate dimension limits 0 - Off 1 - On
  (setvar "DIMLTEX1" "BYBLOCK")    ;;  "."    ;;Linetype extension line 1
  (setvar "DIMLTEX2" "BYBLOCK")    ;;  "."    ;;Linetype extension line 2
  (setvar "DIMLTYPE" "BYBLOCK")    ;;  "."    ;;Dimension linetype
;  (setvar "DIMLUNIT"  2)    ;; 2              ;;Dimension Units (except angular) - number type
;  (setvar "DIMLWD"   -2)    ;; -2             ;;Dimension Line Lineweights
;  (setvar "DIMLWE"   -2)    ;; -2             ;;Extension Line Line Weight
;;(setvar "DIMMZF")         ;;                ;;Sub-zero factor for metric dimensions - Unknown variable
;;(setvar "DIMMZS")         ;;                ;;Sub-zero suffix for metric dimensions - Unknown variable
;  (setvar "DIMPOST" "")     ;; ""             ;;Prefix and suffix for dimension text
;  (setvar "DIMRND"   0)     ;; 0              ;;Dimension Round distance to nearest n
;  (setvar "DIMSAH"   0)     ;; 0              ;;Separate arrow blocks 0 - Off 1 - On
;  (setvar "DIMSCALE" 1)     ;; 1              ;;Dimension Scale Factor
;  (setvar "DIMSD1"   0)     ;; 0              ;;Suppress the first dimension line 0 - Off 1 - On
;  (setvar "DIMSD2"   0)     ;; 0              ;;Suppress the second dimension line 0 - Off 1 - On
;  (setvar "DIMSE1"   0)     ;; 0              ;;Suppress the first extension line 0 - Off 1 - On
;  (setvar "DIMSE2"   0)     ;; 0              ;;Suppress the second extension line 0 - Off 1 - On
;  (setvar "DIMSOXD"  0)     ;; 0              ;;Suppress outside dimension lines
;  (setvar "DIMTAD"   0)     ;; 0              ;;Dimension Text Vertical distance
;  (setvar "DIMTDEC"  4)     ;; 4              ;;Tolerance decimal places
;  (setvar "DIMTFAC"  1)     ;; 1              ;;Dimension text scale factor of fractions relative to text height
;  (setvar "DIMTFILL" 0)     ;; 0              ;;Text background enabled
;  (setvar "DIMTFILLCLR" 0)  ;; 0              ;;Text background color 0: ByLayer, 256 ByBlock
;  (setvar "DIMTIH"   0)     ;; 0              ;;Text inside extensions is horizontal 0 - Off 1 - On
;  (setvar "DIMTIX"   0)     ;; 0              ;;Place text inside extensions 0 - Off 1 - On
;  (setvar "DIMTM"    0)     ;; 0              ;;Dimension Minus tolerance distance when used with dimtol, or dimlim
;  (setvar "DIMTMOVE" 0)     ;; 0              ;;Text movement
;  (setvar "DIMTOFL"  0)     ;; 0              ;;Force line inside extension lines 0 - Off 1 - On
;  (setvar "DIMTOH"   1)     ;; 1              ;;Text outside horizontal 0 - Off 1 - On
;  (setvar "DIMTOL"   0)     ;; 0              ;;Tolerance dimensioning 0 - Off 1 - On
;  (setvar "DIMTOLJ"  1)     ;; 0              ;;Tolerance vertical justification
;  (setvar "DIMTP"    0)     ;; 0              ;;Dimension Plus tolerance distance when used with dimtol, or dimlim
;  (setvar "DIMTSZ" 0.00)    ;; 0              ;;Tick size
;  (setvar "DIMTVP" 0.00)    ;; 0              ;;Text vertical position
  (setvar "DIMTXSTY" FontName)     ;; Font    ;;Text style
  (setvar "DIMTXT" FontHeight)     ;; 0.18 / 2.5   ;;Dimension text Height
;;(setvar "DIMTXTDIRECTIONOff" 0)  ;;         ;;Dimension text direction 1 or 0 - NOT SURE IF THIS WORKS
;  (setvar "DIMTZIN"  8)     ;; 8              ;;Suppresses leading zeros in tolerance values
;  (setvar "DIMUPT"   0)     ;; 0              ;;User positioned text 0 - Off 1 - On
;  (setvar "DIMZIN"   8)     ;; 8              ;;Suppresses leading zeroes

 

 

try that for a start

Link to comment
Share on other sites

18 hours ago, tombu said:

I use macros to quickly import dimension styles from another template or drawing file using Lee Mac's Steal From Drawing lisp. The code could just as easily be added to acaddoc.lsp to run every time a drawing is opened if that's how you prefer.

 

If you reply with the path and name of a dwt or dwg file with a list of dimension styles and anything Lee shows can be imported with the lisp I'll write the macro or code for you if you want.

I use that lisp for everything. Thanks Lee!

Path is "D:\Andi\Program\Dimstyle.dwg" I have created required dimension style (00000204F7189418) in this drawing file. I want to use this dimension style for my projects every time. Please advise how to use this with macro.

Link to comment
Share on other sites

(defun C:DStyle ()
  (Steal "D:\\Andi\\Program\\Dimstyle.dwg" '(( "Dimension Styles" ("00000204F7189418"))))
  (princ)
)

 

Edited by mhupp
  • Like 1
Link to comment
Share on other sites

1 hour ago, Andi said:

Path is "D:\Andi\Program\Dimstyle.dwg" I have created required dimension style (00000204F7189418) in this drawing file. I want to use this dimension style for my projects every time. Please advise how to use this with macro.

First make sure you've saved Lee's lisp in a Trusted Support folder!

This macro should work as \ pauses for user input I've used (chr 92) which when entered at the command line returns "\\" the seperater 

^C^C^P(or C:Steal (load "StealV1-8.lsp"))(Steal (strcat "D:" (chr 92) "Andi" (chr 92) "Program" (chr 92) "Dimstyle.dwg") '(("Dimension Styles"("00000204F7189418")))) .regen

or at the command or added as a line to acaddoc.lsp file to load it into any drawing you open

(or C:Steal (load "StealV1-8.lsp"))(Steal (strcat "D:" (chr 92) "Andi" (chr 92) "Program" (chr 92) "Dimstyle.dwg") '(("Dimension Styles"("00000204F7189418"))))

 

Edited by tombu
  • Like 1
Link to comment
Share on other sites

D'Oh!! and D'Oh again.. beaten to it again.....

 

 

 

A bit of a brute force method below though without stealing form another drawing, hoping I copied and pasted all the parts you need.

 

Problem I have had in the past is that our IT mess up file paths with each server upgrade or so it seams, I'd prefer to avoid reference drawings for steal. Run with the command jefflist as a nod to the reference I posted above.

 

 

An interesting one for just after dinner here. Just seen I refer to 'reverse Jeff' in the notes, that's another thing entirely, don't worry about that.

 

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:jefflist ( / DimStyleName DSN FontStyleName FSN DimensionScale dimvariableslist)

;;;;;;;;;;A List using reversejeff of all the dimension variables. Copy and paste from clipboard to here ;;;;;;;;;;;;;;

  (setq DimName "00000204F71894182")
  (setq dimvariableslist (list 0 0 2 25.4 0.0 2 0 2 0 "" 0 0.85 3 0 0 "" "" "" 0.09 1 1 1 4 0.0 0.38 "." 0.18 0.0625 2 1.0 0 0.09 0.785398 0 "" 1.0 0 "ByBlock" "ByBlock" "ByBlock" 5 -2 -2 "\"" 0.0 0 1.0 0 0 0 0 0 0 4 1.0 0 0 1 0 0.0 0 0 1 0 1 0.0 0.0 0.0 "Standard" 0.63 0 0 0))


;; See below for description of each item in this list
;;;;;;;;;;End of dimension description ;;;;;;;;;;;;;;



;;Sub Routines
  (defun tablesearch ( s / d r) ;;List Dimstyles
    (while (setq d (tblnext s (null d)))
      (setq r (cons (cdr (assoc 2 d)) r))
    )
  )

  (defun mytextstyle ( myfont / mytextstyle fontcount fontlist) ;;check textstyle is loaded
  ;;Font Style Lists
  ;;Fontname Height WidthFactor ObliqueAngle Backwards UpsideDown
    (setq fontstyles (list
      (list "Standard" "Arial" "0.0000" "1.0000" "0" "No" "No")
      (list "romans" "romans.shx" "0.0000" "1.0000" "0" "No" "No")
      (list "CoArial" "Arial" "0.0000" "1.0000" "0" "No" "No")
      (list "Company_Arial" "Arial" "0.0000" "1.0000" "0" "No" "No")
    ));end fontstyles list

   (if (member myfont (tableSearch "style"))
    (princ "Font Is Loaded")
    (progn ;font isn't loaded
      (setq fontcount 0)
      (while (< fontcount (length fontstyles))
        (if (= (strcase (nth 0 (nth fontcount fontstyles))) (strcase myfont))
          (progn ;font style is loaded
            (setq fontlist fontcount) ;;font style exists
          ) ; end progn
        ) ;end if
        (setq fontcount (+ 1 fontcount))
      )
  
      (if (= fontlist nil)
        (progn ;;if font is not defined above or loaded
          (alert "Font style needs loading. Please edit it")
          (command "Style" myfont "romans.shx" "0.0000" "1.0000" "0" "No" "No" "No")
          (initdia)
          (command "style")
        ) ;end progn
        (progn
          (command "style" (nth 0 (nth fontlist fontstyles)) (nth 1 (nth fontlist fontstyles))
                           (nth 2 (nth fontlist fontstyles)) (nth 3 (nth fontlist fontstyles))
                           (nth 4 (nth fontlist fontstyles)) (nth 5 (nth fontlist fontstyles))
                           (nth 6 (nth fontlist fontstyles)) (nth 7 (nth fontlist fontstyles))
          ) ;end command
        ) ;end progn
      ) ;end if
    ) ;end progn
    );end if
    (setq mystyle myfont) ;;text font style.. if anything else check if style is loaded into drawing here
    mystyle
  )
;;End Sub Routines


;;Dimension Style
  (princ "Exsting DIM styles: ")(princ (tableSearch "dimstyle"))
  (setq DimStyleName (nth 0 (tableSearch "dimstyle")))
  (setq DSN DimName)
  (if (or (= dsn nil)(= DSN ""))
    (setq DimStyleName DimStyleName)
    (setq DimStyleName DSN)
  ) 

;;Font Style
  (princ  "Loaded Text Fonts: ")(princ (tableSearch "style"))
  (setq FontStyleName (nth 0 (tableSearch "style")))
  (setq FSN (nth 68 dimvariableslist) )
  (if (or (= dsn nil)(= DSN ""))
    (setq FontStyleName FontStyleName)
    (setq FontStyleName FSN)
  ) 
  (mytextstyle FontStyleName)

;;Full list of dimension variables.
;;Change all or none as required, save and existing style to update
;;NOTE: BYBLOCK and other texts to be numbers?
;;https://help.autodesk.com/view/ACDLTM/2016/ENU/?guid=GUID-30F44A49-4250-42D1-AEF2-5E2914ADB02B
 (setvar "DIMADEC"    (nth  0 dimvariableslist));;Angular Dimension Decimal Places
  (setvar "DIMALT"    (nth  1 dimvariableslist));;Control of alternative units 0 - Off 1 - On
  (setvar "DIMALTD"   (nth  2 dimvariableslist));;Alternative Units Decimal Places
  (setvar "DIMALTF"   (nth  3 dimvariableslist));;Alternative Units Scale Factor
  (setvar "DIMALTRND" (nth  4 dimvariableslist));;Alternate units rounding value
  (setvar "DIMALTTD"  (nth  5 dimvariableslist));;Alternative Units Tolerance Decimal Places
  (setvar "DIMALTTZ"  (nth  6 dimvariableslist));;Alternate tolerance zero suppression
  (setvar "DIMALTU"   (nth  7 dimvariableslist));;Alternative Units Units
  (setvar "DIMALTZ"   (nth  8 dimvariableslist));;Alternate unit zero suppression
  (setvar "DIMAPOST"  (nth  9 dimvariableslist));;Prefix and suffix for alternate text
  (setvar "DIMARCSYM" (nth 10 dimvariableslist));;Arc Length Dimension Arc Symbol
  (setvar "DIMASZ"    (nth 11 dimvariableslist));;Dimension Line and Leader Line Arrow Heads size
  (setvar "DIMATFIT"  (nth 12 dimvariableslist));;Arrow and text fit if distance is too narrow for both
  (setvar "DIMAUNIT"  (nth 13 dimvariableslist));;Angular unit format
  (setvar "DIMAZIN"   (nth 14 dimvariableslist));;Angular Dimension Depresses leading zeros
  (setvar "DIMBLK"    (nth 15 dimvariableslist));;Arrow block name "." for closed flled else as properties
  (setvar "DIMBLK1"   (nth 16 dimvariableslist));;First arrow block name "." for closed flled else as properties
  (setvar "DIMBLK2"   (nth 17 dimvariableslist));;Second arrow block name "." for closed flled else as properties
  (setvar "DIMCEN"    (nth 18 dimvariableslist));;Drawing centre mark for radius or diameter dimensions
  (setvar "DIMCLRD"   (nth 19 dimvariableslist));;Colours - Lines, ArrowHeads, Dimension Lines 0: ByLayer, 256 ByBlock
  (setvar "DIMCLRE"   (nth 20 dimvariableslist));;Colours - Extension Lines, Centre Marks Colours 0: ByLayer, 256 ByBlock
  (setvar "DIMCLRT"   (nth 21 dimvariableslist));;Colours - Dimension Text Colour 0: ByLayer, 256 ByBlock
  (setvar "DIMDEC"    (nth 22 dimvariableslist));;Dimension Decimal Places
  (setvar "DIMDLE"    (nth 23 dimvariableslist));;Dimension Line extension with oblique strokes instead of arrows
  (setvar "DIMDLI"    (nth 24 dimvariableslist));;Dimension Baseline Dimension Spacing
  (setvar "DIMDSEP"   (nth 25 dimvariableslist));;Decimal separator
  (setvar "DIMEXE"    (nth 26 dimvariableslist));;Extension Line Extension distance
  (setvar "DIMEXO"    (nth 27 dimvariableslist));;Extension Line Offset
  (setvar "DIMFRAC"   (nth 28 dimvariableslist));;Dimension Fraction Format
  (setvar "DIMFXL"    (nth 29 dimvariableslist));;Fixed Extension Line
  (setvar "DIMFXLON"  (nth 30 dimvariableslist));;Enable Fixed Extension Line 0 - Off 1 - On
  (setvar "DIMGAP"    (nth 31 dimvariableslist));;Dimension gap between text and arrow 
  (setvar "DIMJOGANG" (nth 32 dimvariableslist));;Radius dimension jog angle.. radians?
  (setvar "DIMJUST"   (nth 33 dimvariableslist));;Justification of text on dimension line
  (setvar "DIMLDRBLK" (nth 34 dimvariableslist));;Leader block name "." for closed flled else as properties
  (setvar "DIMLFAC"   (nth 35 dimvariableslist));;Linear unit scale factor
  (setvar "DIMLIM"    (nth 36 dimvariableslist));;Generate dimension limits 0 - Off 1 - On
  (setvar "DIMLTEX1"  (nth 37 dimvariableslist));;Linetype extension line 1
  (setvar "DIMLTEX2"  (nth 38 dimvariableslist));;Linetype extension line 2
  (setvar "DIMLTYPE"  (nth 39 dimvariableslist));;Dimension linetype
  (setvar "DIMLUNIT"  (nth 40 dimvariableslist));;Dimension Units (except angular) - number type
  (setvar "DIMLWD"    (nth 41 dimvariableslist));;Dimension Line Lineweights
  (setvar "DIMLWE"    (nth 42 dimvariableslist));;Extension Line Line Weight
  (setvar "DIMPOST"   (nth 43 dimvariableslist));;Prefix and suffix for dimension text
  (setvar "DIMRND"    (nth 44 dimvariableslist));;Dimension Round distance to nearest n
  (setvar "DIMSAH"    (nth 45 dimvariableslist));;Separate arrow blocks 0 - Off 1 - On
  (setvar "DIMSCALE"  (nth 46 dimvariableslist));;Dimension Scale Factor
  (setvar "DIMSD1"    (nth 47 dimvariableslist));;Suppress the first dimension line 0 - Off 1 - On
  (setvar "DIMSD2"    (nth 48 dimvariableslist));;Suppress the second dimension line 0 - Off 1 - On
  (setvar "DIMSE1"    (nth 49 dimvariableslist));;Suppress the first extension line 0 - Off 1 - On
  (setvar "DIMSE2"    (nth 50 dimvariableslist));;Suppress the second extension line 0 - Off 1 - On
  (setvar "DIMSOXD"   (nth 51 dimvariableslist));;Suppress outside dimension lines
  (setvar "DIMTAD"    (nth 52 dimvariableslist));;Dimension Text Vertical distance
  (setvar "DIMTDEC"   (nth 53 dimvariableslist));;Tolerance decimal places
  (setvar "DIMTFAC"   (nth 54 dimvariableslist));;Dimension text scale factor of fractions relative to text height
  (setvar "DIMTFILL"  (nth 55 dimvariableslist));;Text background enabled
  (setvar "DIMTFILLCLR" (nth 56 dimvariableslist));;Text background color 0: ByLayer, 256 ByBlock
  (setvar "DIMTIH"    (nth 57 dimvariableslist));;Text inside extensions is horizontal 0 - Off 1 - On
  (setvar "DIMTIX"    (nth 58 dimvariableslist));;Place text inside extensions 0 - Off 1 - On
  (setvar "DIMTM"     (nth 59 dimvariableslist));;Dimension Minus tolerance distance when used with dimtol, or dimlim
  (setvar "DIMTMOVE"  (nth 60 dimvariableslist));;Text movement
  (setvar "DIMTOFL"   (nth 61 dimvariableslist));;Force line inside extension lines 0 - Off 1 - On
  (setvar "DIMTOH"    (nth 62 dimvariableslist));;Text outside horizontal 0 - Off 1 - On
  (setvar "DIMTOL"    (nth 63 dimvariableslist));;Tolerance dimensioning 0 - Off 1 - On
  (setvar "DIMTOLJ"   (nth 64 dimvariableslist));;Tolerance vertical justification
  (setvar "DIMTP"     (nth 65 dimvariableslist));;Dimension Plus tolerance distance when used with dimtol, or dimlim
  (setvar "DIMTSZ"    (nth 66 dimvariableslist));;Tick size
  (setvar "DIMTVP"    (nth 67 dimvariableslist));;Text vertical position
  (setvar "DIMTXSTY"  (nth 68 dimvariableslist));;Text style
  (setvar "DIMTXT"    (nth 69 dimvariableslist));;Dimension text Height
  (setvar "DIMTZIN"   (nth 70 dimvariableslist));;Suppresses leading zeros in tolerance values
  (setvar "DIMUPT"    (nth 71 dimvariableslist));;User positioned text 0 - Off 1 - On
  (setvar "DIMZIN"    (nth 72 dimvariableslist));;Suppresses leading zeroes

;;Set Dimstyle named above to this list
  (setq dimstylelist (tableSearch "dimstyle"))
  (if (= (member DimStyleName dimstylelist) nil)
    (command "dimstyle" "s" DimStyleName)
    (command "dimstyle" "s" DimStyleName "Y")
  )
    (princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

Edited by Steven P
  • Like 1
Link to comment
Share on other sites

11 minutes ago, mhupp said:
(defun C:DStyle ()
  (Steal "D:\Andi\Program\Dimstyle.dwg" '(( "Dimension Styles" ("00000204F7189418"))))
  (princ)
)

 

In Lee's example he uses "\\" not "\" though. No way of testing either of ours as we don't have that path on our PC's.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...