muck Posted January 9, 2009 Share Posted January 9, 2009 Subject: Using VBA to create Annotative Dim in DimStyle object. AutoCAD 2009 VBA How can someone use VBA make a dimstyle that will make an annotative dimension? Thank you, Quote Link to comment Share on other sites More sharing options...
CmdrDuh Posted January 9, 2009 Share Posted January 9, 2009 you have to set the annotative property to true. Let me look for an example Never mind, that was something new for C#, not VBA Quote Link to comment Share on other sites More sharing options...
muck Posted January 9, 2009 Author Share Posted January 9, 2009 How to you set the annotative property. I have done an internet search without any luck. Thank you, Quote Link to comment Share on other sites More sharing options...
RickyD302 Posted January 13, 2009 Share Posted January 13, 2009 DIMANNO needs to be set to 1 This routines will create a s dim style. I actually have this routine use part the the stylename to set the dimscale and I read stuff from a file I created. SYSVDLG is a great command to find out what the system variable are currently set to. I had to strip move of the code down to stay with in the posting rules. HTH Public Sub MakeDimStyle(stylename As String) ' initial variables Dim objDimStyle As AcadDimStyle Dim objDimCollection As AcadDimStyles Dim strDimStyles(2) As String Dim strWhichSpace As String Dim strWhichPaper As String Dim intPos As Integer Dim sTemp1 As String Dim strvar As String Dim varValue As Variant Dim strValue As String Dim i As Integer Dim dbldimscale As Double Dim lngValue As Long Dim stemp As String Dim lenstr As Integer Dim IntInFile As Integer Dim file2use As String file2use = Left(stylename, 3) & "0" lenstr = Len(stylename) dbldimscale = CDbl(Right(stylename, lenstr - 3)) On Error Resume Next Set objDimStyle = ThisDrawing.DimStyles.Item(stylename) If Err Then On Error GoTo 0 Set objDimStyle = ThisDrawing.DimStyles.Add(stylename) ThisDrawing.ActiveDimStyle = objDimStyle '--- CHANGE YOUR DIM VARIABLE HERE------ ThisDrawing.SetVariable "DIMANNO",1 objDimStyle.CopyFrom ThisDrawing End Sub Quote Link to comment Share on other sites More sharing options...
CmdrDuh Posted January 14, 2009 Share Posted January 14, 2009 Dimanno is read only in 08 and 09, so I am curious how your making it work Quote Link to comment Share on other sites More sharing options...
muck Posted January 14, 2009 Author Share Posted January 14, 2009 I am wonding about Dimanno being is read only. I am using 2009. My code uses sendcommand to reset dimanno but I have not looked at the posted above code. Here is my code. It is at 'Annotation Dim flagged note. My code is changing dimstyle picking a dimension and that is my objective in my code. Only way I know how to do it is to use sendcommnd shown in the last part of my code. Dim objDimension As AcadDimension Dim varPickedPoint As Variant Dim objDimStyle As AcadDimStyle Dim strDimStyles As String Dim strChosenDimStyle As String Dim stg As String On Error Resume Next Me.hide ThisDrawing.Utility.GetEntity objDimension, varPickedPoint, _ "Picked a dimension whose style you wish to set" If objDimension Is Nothing Then MsgBox "You failed to pick a dimension object" Exit Sub End If stg = "Textheight" ThisDrawing.SetVariable "dimexe", objDimension.ExtensionLineExtend ThisDrawing.SetVariable "dimexo", objDimension.ExtensionLineOffset ThisDrawing.SetVariable "DIMCLRD", objDimension.DimensionLineColor ThisDrawing.SetVariable "DIMCLRE", objDimension.ExtensionLineColor ThisDrawing.SetVariable "DIMCLRT", objDimension.color ThisDrawing.SetVariable "Dimscale", objDimension.ScaleFactor ThisDrawing.SendCommand "Dimscale" & vbCr ThisDrawing.SendCommand objDimension.ScaleFactor & vbCr ThisDrawing.SetVariable "DIMTAD", objDimension.VerticalTextPosition ThisDrawing.SetVariable "DIMTXT", objDimension.TextHeight ThisDrawing.DimStyles.StyleName , objDimension.TextStyle ThisDrawing.SetVariable "DIMJUST", objDimension.TextGap ThisDrawing.SetVariable "DIMASZ", objDimension.ArrowheadSize ThisDrawing.SetVariable "Clayer", objDimension.Layer Set objDimStyle = ThisDrawing.DimStyles.Add("YourNamedStyle") objDimStyle.CopyFrom ThisDrawing ThisDrawing.ActiveDimStyle = objDimStyle objDimStyle.CopyFrom ThisDrawing objDimStyle.Name = "YourNamedStyle" 'Annotation Dim If objDimension.ScaleFactor = 0 Then ThisDrawing.SendCommand "-dimstyle" & vbCr & "AN" & vbCr & "Y" & vbCr & "YourNamedStyle" & vbCr & "Y" & vbCr & "s" & vbCr & vbCr Else ThisDrawing.SendCommand "-dimstyle" & vbCr & "AN" & vbCr & "N" & vbCr & "YourNamedStyle" & vbCr & "Y" & vbCr & "s" & vbCr & vbCr End If ThisDrawing.SetVariable "Dimscale", objDimension.ScaleFactor ThisDrawing.SendCommand "Dimscale" & vbCr ThisDrawing.SendCommand objDimension.ScaleFactor & vbCr Quote Link to comment Share on other sites More sharing options...
CmdrDuh Posted January 14, 2009 Share Posted January 14, 2009 Well, using sendcommand is entirely different than setting dimanno through code. What happens if you type DIMANNO at the command prompt? does it register as readonly? Quote Link to comment Share on other sites More sharing options...
muck Posted January 19, 2009 Author Share Posted January 19, 2009 Yes, code is preferred over sendcommand. I will look at above code to see if I can replace the Sendcommand with code. Thank you, Quote Link to comment Share on other sites More sharing options...
muck Posted January 20, 2009 Author Share Posted January 20, 2009 In RickyD302's code, what is the line dbldimscale = CDbl(Right(stylename, lenstr - 3)) for? In that code, I set the dimstyle name to "test1" and it would not get thru that line? Thank you Quote Link to comment Share on other sites More sharing options...
RickyD302 Posted January 27, 2009 Share Posted January 27, 2009 I'm sorry I use that to set the dimscale of the style. I'm having the user enter CSI0 or CSI48 for the style and I'm stripping off the CSI Quote Link to comment Share on other sites More sharing options...
RickyD302 Posted January 27, 2009 Share Posted January 27, 2009 My Bad peoples....When I ran sysvdlg I didn't noticte the read-only. I tried to change DIMANNO to 1 via my code and is just exit my MakeDimStyle routine without error but didn't set it to one either. 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.