mra_leo Posted May 15, 2011 Share Posted May 15, 2011 Dear All, i m New in Autocad VBA, I need help, m creating a new dimension style, now i want to edit/modify dimension style variables. can any one help me, how i write that code, Thanks, Ramzan Quote Link to comment Share on other sites More sharing options...
borgunit Posted June 27, 2011 Share Posted June 27, 2011 It is a curious thing. You first create a new dimstyle. You create change all of the dim variables to the way you want them. You then copy the vars from the drawing to your new dimstyle. This is the same method to change the existing dimstyle variables without having them appear as overrides. Public Sub UgDimStyle_CreateNew( _ Optional ByVal sDimStyName As String = "Standard_Dim") '------------------------------------------------------------------------------ ' ' '------------------------------------------------------------------------------ Dim CurDimStyle As AcadDimStyle Dim NewDimstyle As AcadDimStyle Dim iAltUnits As Integer Dim dDimScale As Double ''''''''''''''''''''''''''''''''''''''' 'Save copy of current dimstyle Set CurDimStyle = ThisDrawing.ActiveDimStyle 'Create new dimstyle Set NewDimstyle = ThisDrawing.DimStyles.Add(sDimStyName) 'Set newly created dimstyle current ThisDrawing.ActiveDimStyle = NewDimstyle 'Save the target "dimvar" values dDimScale = ThisDrawing.GetVariable("Dimscale") iAltUnits = ThisDrawing.GetVariable("Dimalt") '------------------------------------------------------------------------------ 'Alter the target "dimvar" values '------------------------------------------------------------------------------ ThisDrawing.SetVariable "DIMSCALE", 1# 'will control size of dim text ThisDrawing.SetVariable "DIMASZ", 2.5 'arrowhead size ThisDrawing.SetVariable "DIMATFIT", 2 'arrow-text arrangement ThisDrawing.SetVariable "DIMAZIN", 3 '0 suppression before/after angular ThisDrawing.SetVariable "DIMBLK", "" 'special arrow blk ThisDrawing.SetVariable "DIMDLE", 0 'dim line extension past extension ThisDrawing.SetVariable "DIMDLI", 10 'dist between baseline dims ThisDrawing.SetVariable "DIMDSEP", "." 'decimal separator ThisDrawing.SetVariable "DIMEXE", 1 'dim line extension past extension ThisDrawing.SetVariable "DIMEXO", 1 'dim offset from origin 'ThisDrawing.SetVariable "DIMFIT", 5 'control fit if not enough space ThisDrawing.SetVariable "DIMGAP", 2 'gap around text ThisDrawing.SetVariable "DIMJUST", 0 'text placement - above centered ThisDrawing.SetVariable "DIMLFAC", 1# 'length scaling ThisDrawing.SetVariable "DIMTAD", 1 'text to dim placement - above ThisDrawing.SetVariable "DIMTIH", 0 'aligned with dim ThisDrawing.SetVariable "DIMTIX", 0 'force inside ThisDrawing.SetVariable "DIMTMOVE", 0 'dim moves with text ThisDrawing.SetVariable "DIMTSZ", 0 'draw arrowheads ThisDrawing.SetVariable "DIMTXT", 3.5 'text height ThisDrawing.SetVariable "DIMTZIN", 12 '0 suppression before/after tol ThisDrawing.SetVariable "DIMUNIT", 2 'unit format - decimal ThisDrawing.SetVariable "DIMZIN", 12 '0 suppression before/after 'Copy new document dimvar settings into new dimstyle NewDimstyle.CopyFrom ThisDrawing 'Set original dimstyle current 'ThisDrawing.ActiveDimStyle = CurDimStyle 'Restore the altered "dimvar" values ''ThisDrawing.SetVariable "Dimscale", dDimScale ''ThisDrawing.SetVariable "Dimalt", iAltUnits 'Copy restored document dimvar settings into original dimstyle ''CurDimStyle.CopyFrom ThisDrawing Set CurDimStyle = Nothing Set NewDimstyle = Nothing End Sub Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.