Jump to content

match Dimension property


Andi
 Share

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
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
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 1
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
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.

 Share

×
×
  • Create New...