+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Super Member
    Using
    not specified
    Join Date
    Feb 2006
    Posts
    614

    Default Using VBA to create Annotative Dim in DimStyle object?

    Registered forum members do not see this ad.

    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,

  2. #2
    Senior Member CmdrDuh's Avatar
    Computer Details
    CmdrDuh's Computer Details
    Computer:
    HP workstation xw8200
    RAM:
    2gig, soon to be 4
    Monitor:
    Dual 21s
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    AZ, USA
    Posts
    396

    Default

    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
    Last edited by CmdrDuh; 9th Jan 2009 at 05:04 pm.
    Everyone has a Photographic memory, some just don't have film

  3. #3
    Super Member
    Using
    not specified
    Join Date
    Feb 2006
    Posts
    614

    Default

    How to you set the annotative property. I have done an internet
    search without any luck.
    Thank you,

  4. #4
    Full Member
    Using
    AutoCAD 2011
    Join Date
    May 2006
    Posts
    27

    Default System Variable

    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

  5. #5
    Senior Member CmdrDuh's Avatar
    Computer Details
    CmdrDuh's Computer Details
    Computer:
    HP workstation xw8200
    RAM:
    2gig, soon to be 4
    Monitor:
    Dual 21s
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    AZ, USA
    Posts
    396

    Default

    Dimanno is read only in 08 and 09, so I am curious how your making it work
    Everyone has a Photographic memory, some just don't have film

  6. #6
    Super Member
    Using
    not specified
    Join Date
    Feb 2006
    Posts
    614

    Default

    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

  7. #7
    Senior Member CmdrDuh's Avatar
    Computer Details
    CmdrDuh's Computer Details
    Computer:
    HP workstation xw8200
    RAM:
    2gig, soon to be 4
    Monitor:
    Dual 21s
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    AZ, USA
    Posts
    396

    Default

    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?
    Everyone has a Photographic memory, some just don't have film

  8. #8
    Super Member
    Using
    not specified
    Join Date
    Feb 2006
    Posts
    614

    Default

    Yes, code is preferred over sendcommand. I will look at above code to
    see if I can replace the Sendcommand with code.
    Thank you,

  9. #9
    Super Member
    Using
    not specified
    Join Date
    Feb 2006
    Posts
    614

    Default dbldimscale = CDbl(Right(stylename, lenstr - 3)) ?

    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

  10. #10
    Full Member
    Using
    AutoCAD 2011
    Join Date
    May 2006
    Posts
    27

    Default

    Registered forum members do not see this ad.

    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

Similar Threads

  1. ActiveX component can't create Object
    By Kirk Mac in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 4th Apr 2007, 12:27 pm
  2. Try to create a trapezoid object
    By gwkwong in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 2nd Nov 2006, 11:12 pm
  3. Create a field linked to an object
    By CAD Panacea in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 7th Sep 2006, 02:02 pm
  4. fail to create CommCntrClientSink object! (what is this?)
    By gardenmd in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 22nd Jan 2006, 08:58 pm
  5. Converting T/F/S views to create 3D object
    By speedy3020 in forum AutoCAD General
    Replies: 6
    Last Post: 16th Feb 2005, 11:34 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts