Jump to content

Modify DimStyles with VBA


-KarL-

Recommended Posts

I am looking for a way to modify a dim style. Mainly the color of the text and dim lines. I have tried searching the forum but have not been able to find anything that works yet.

 

Thanks for any help

-KarL-

Link to comment
Share on other sites

Sorry, pasted something from the help file, but now I see the problem.

I don't find the proerties you need in the dimstyle object.

 

Maybe you have to do it with SendCommand or simmilar, as in a script.

Link to comment
Share on other sites

Option Explicit

Public Sub DWGSetup()

Dim objstyle As AcadTextStyle

Dim objLayer As AcadLayer

Dim objlinetype As AcadLineType

Dim objDimStyle As AcadDimStyle

Dim SysvarName As String

Dim dblVardata As Double

Dim strVarData As String

Dim sysVarData As Variant

Dim DataType As Integer

Dim intData As Integer

ThisDrawing.SetVariable "expert", 5

ThisDrawing.ActiveLayer = ThisDrawing.Layers("0")

 

Set objDimStyle = ThisDrawing.DimStyles.Add("TEP")

objDimStyle.CopyFrom ThisDrawing

ThisDrawing.ActiveDimStyle = objDimStyle

SysvarName = "PLINEGEN"

intData = 1

ThisDrawing.SetVariable SysvarName, intData

SysvarName = "DIMALTF"

dblVardata = 25.4

ThisDrawing.SetVariable SysvarName, dblVardata

SysvarName = "DIMAPOST"

strVarData = ""

ThisDrawing.SetVariable SysvarName, strVarData

objDimStyle.CopyFrom ThisDrawing

ThisDrawing.Regen acAllViewports

End Sub

Link to comment
Share on other sites

  • 6 months later...

Thanks for the code. Works fine for me except one thing...the changes aren't seen on-screen until I manually go into the DimStyle Dialog, Select the Style I changed and click Modify, then I have to click OK. I have to repeat that process for each DimStyle I modified.

 

The only variation I did from the code above is that I used an assigned objDrawing variable instead of ThisDrawing.

 

Thanks for any direction you can provide...

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