objectdbx and dll's

Discussion in 'AutoCAD' started by Mark Dubbelaar, Oct 12, 2004.

  1. hi

    i'm having a bit of trouble with object dbx and dll's, i've recently
    compiled all my common code into a dll file, some of the functions include
    references to objectdbx... but for some reason when i try and use the dll in
    my routines a type mismatch error appears whenever i use a function that
    uses the objectdbx object... at the moment i'm declairing the a variable for
    the objectdbx to be an 'object' is this the correct type for objectdbx???
    can you use an objectdbx object in a dll file??? an example of one of the
    functions that i've compiled to dll is as follows:

    'code
    Public Function LayerExists(oTargetDrawing As Object, sLayerName As String)
    As Boolean

    Dim eLayer As AcadLayer

    For Each eLayer In oTargetDrawing.Layers
    If UCase(eLayer.Name) = UCase(sLayerName) Then
    LayerExists = True
    Set eLayer = Nothing
    Exit Function
    End If
    Next eLayer

    LayerExists = False

    Set eLayer = Nothing

    End Function
    'code end


    the oTargetDrawing is usually either 'thisdrawing' or the objectdbx object

    any help would be great

    cheers

    mark
     
    Mark Dubbelaar, Oct 12, 2004
    #1
  2. Mark Dubbelaar

    jdinardi Guest

    What line are you getting the type mismatch on

    I wouldn't think that objectdbx would complain if you use a generic object argument in your function as long as you pass a valid axdbDocument or acadDocument object to the function as long as both objects support the properties, methods, etc that you're calling within the function.

    Regards,
    Jacob Dinardi
     
    jdinardi, Oct 12, 2004
    #2
  3. below is just some sample code, that uses the layerexist function posted on
    the original post... using both the current drawing and an objectdbx object.

    Option Explicit

    Sub test()

    Dim odCLayer As dCLayer

    Set odCLayer = New dCLayer

    If odCLayer.LayerExists(ThisDrawing, "0") = True Then '<----- holts
    here 'Type mismatch'
    MsgBox "Layer exists"
    Else
    MsgBox "cannot find layer"
    End If

    End Sub


    Sub testDBX()

    Dim odCLayer As dCLayer
    Dim oObjectDBX As Object
    Dim sFileName As String

    Set odCLayer = New dCLayer
    Set oObjectDBX =
    AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument.16")

    sFileName = "c:\Drawing1.dwg"
    oObjectDBX.Open sFileName

    If odCLayer.LayerExists(oObjectDBX, "0") = True Then '<----- holts
    here 'Type mismatch'
    MsgBox "Layer exists"
    Else
    MsgBox "cannot find layer"
    End If

    End Sub


    cheers

    mark


    object argument in your function as long as you pass a valid axdbDocument or
    acadDocument object to the function as long as both objects support the
    properties, methods, etc that you're calling within the function.
     
    Mark Dubbelaar, Oct 12, 2004
    #3
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.