Dimstyle Object and ObjectDBX

Discussion in 'AutoCAD' started by xxxTed Schaefer, Feb 11, 2004.

  1. Why is the Dimstyle object so limited and doesn't operate at all like the
    textstyle object?

    Does anyone know: Using the high speed background processing of ObjectDBX
    from vba, how do you get the dimstyles and their settings?

    - Ted Schaefer, WD Partners
     
    xxxTed Schaefer, Feb 11, 2004
    #1
  2. Some code:

    'This works
    Private Sub ProcessTextStyles(oDbxDwg As AxDbDocument)
    Dim oTxtStyle As AcadTextStyle
    For Each oTxtStyle In oDbxDwg.TextStyles
    With oTxtStyle
    oClsDB.AddTextStyle .Name, .fontFile, .Height, .Width, oDbxDwg.Name
    End With
    Next
    End Sub

    'This does NOT work
    Private Sub ProcessDimStyles(oDbxDwg As AxDbDocument)
    Dim oDimStyle As AcadDimStyle
    For Each oDimStyle In .DimStyles
    With oDimStyle
    oClsDB.AddDimStyle .Name, .Font, .Rarrow, .Larrow, .lunits, .luprec
    End With
    Next
    End Sub


    'This also does NOT work (I thought if I could copy into a blank drawing, I
    could do something)
    Private Sub ProcessDimStyles(oDbxDwg As AxDbDocument, Optional lngProtoID As
    Long = 0)
    Dim oDs As AcadDimStyle
    Dim oDsName As String
    Dim oDwg As AcadDocument
    Dim oNewDS As AcadDimStyle

    Set oDwg = ThisDrawing

    On Error Resume Next
    For Each oDs In oDbxDwg.DimStyles
    oDsName = oDs.Name
    Set oNewDS = oDwg.DimStyles.Add(oDsName)
    oNewDS.CopyFrom oDs
    Next
    End Sub
     
    xxxTed Schaefer, Feb 11, 2004
    #2
  3. xxxTed Schaefer

    SpeedCAD Guest

    Hi...

    Why is there a point in .DimStyle in the code line?

    For Each oDimStyle In .DimStyles

    I don't see the sentence With

    :S
     
    SpeedCAD, Feb 11, 2004
    #3
  4. I know this is goofy, but what you have to do is use SetVariable to set
    all of the dim** system variables the way you want them, and then use
    the copyfrom method of the DimStyle object, specifying your
    AxDbDocument object as the source object.
     
    Chuck Gabriel, Feb 11, 2004
    #4
  5. xxxTed Schaefer

    Mark Propst Guest

    is this a typo?
    should it be
    ???

    you might look into posts regarding the difference between axdblib objects
    and acadlib objects
    Dim oTxtStyle As AXDB15Lib.AcadTextStyle
    in lieu of
    Dim oTxtStyle As AcadTextStyle

    though I have no idea if that's causing whatever problem you're encountering

    from looking at your copyfrom example i would have thought that that would
    have worked.
    did you confirm the dbx doc was a valid object at the time of calling that
    sub?

    hth
    Mark

     
    Mark Propst, Feb 11, 2004
    #5
  6. Sorry,
    I erased the With objDbxDoc .... End With
    - Ted
     
    xxxTed Schaefer, Feb 11, 2004
    #6
  7. There's no getvar / setvar in ObjectDBX.
     
    xxxTed Schaefer, Feb 11, 2004
    #7
  8. Oops. That'll teach me to read more carefully (I hope).
     
    Chuck Gabriel, Feb 11, 2004
    #8
  9. From Tom Nelson, Developer Technical Services.
    Good reason for ADN. Tom's great!
    This works - Ted

    "I could not find any other reference to this particular issue, but I think
    I have a workaround for you. Using your code, I can copy the Dimstyles into
    a new drawing, but if I attempt to select one from the Dimstyles dialog, a
    fatal error results. However, if I put the Dimstyles into an object array,
    it appears that I can use the CopyObjects method. The following example
    assumes that I have a drawing "c:\test.dwg", which contains the desired
    Dimstyles. See below:"

    <code_begin>
    Public Sub test()
    Dim oAxDoc As New AxDbDocument
    'Assume c:\test.dwg contains additional dimstyles
    oAxDoc.Open "c:\test.dwg"
    Dim objs() As Object
    Dim oDs As AcadDimStyle
    Dim i As Integer
    'Find the dimstyles in c:\test.dwg
    For i = 0 To oAxDoc.DimStyles.Count - 1
    ReDim Preserve objs(i)
    Set objs(i) = oAxDoc.DimStyles(i)
    Next
    'Copy the dimstyles across to the new database
    oAxDoc.CopyObjects objs, ThisDrawing.Database.DimStyles
    End Sub
    <code_end>
     
    xxxTed Schaefer, Feb 12, 2004
    #9
  10. xxxTed Schaefer

    Mark Propst Guest

    Thanks for sharing the solution!
    :)
    Mark
     
    Mark Propst, Feb 12, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.