Still having getinterface object problems...

Discussion in 'AutoCAD' started by Jason Smith, Feb 18, 2004.

  1. Jason Smith

    Jason Smith Guest

    I appreciate the help from the group, but I am still having troubles. I may
    have to give up on this one until I take a full fledged course in vb. I
    just am not sure what I am doing wrong. Is there something inherently wrong
    with my code? I do not have a good understanding of the "MyProj.MyClass"
    part of the GetInterfaceObject method. The exe file runs fine, it just does
    not execute the sub in the dll. Basically, it continues to open all of the
    files in the file list then hangs indefinitely.

    One other thought I had. Is it possible to run code from a dvb project from
    an executable file?

    My code is:

    CleanUp.exe file is as follows: (Project is called CleanUp)

    Public Sub Cleaner()

    On Error Resume Next

    Set AcadApp = GetObject(, "AutoCAD.Application")
    If Err Then
    Err.Clear
    Set AcadApp = CreateObject("AutoCAD.Application")
    End If

    Set DwgClean = AcadApp.GetInterfaceObject("CleanUpDll.Clean") '???

    Dim obj As Object
    Dim lyr As Object
    Dim blk As Object
    Dim piece As Object
    Dim DimSt As Object

    For Each oFile In CleanFileList

    FileCopy SourceLoc + "\" + oFile, WorkingLoc + "\" + oFile
    AcadApp.Documents.Open (WorkingLoc + "\" + oFile)

    Call DwgClean.Clean(AcadApp)


    Next oFile

    End Sub


    The CleanUp.dll file contains: (Project is called CleanUpDll, Class Module
    is called Clean)

    Public Sub Clean(App As AcadApplication)

    Set ThisDrawing = AcadApp.ActiveDocument

    For Each obj In ThisDrawing.ModelSpace
    obj.Color = acByLayer
    Next obj

    For Each lyr In ThisDrawing.Layers
    lyr.Color = 8
    Next lyr

    For Each blk In ThisDrawing.Blocks
    For Each piece In blk
    piece.Color = acByLayer
    Next piece
    Next blk

    For Each DimSt In ThisDrawing.DimStyles
    ThisDrawing.ActiveDimStyle =
    AcadApplication.ActiveDocument.DimStyles(DimSt.Name)
    ThisDrawing.SetVariable "DIMCLRD", acByLayer
    ThisDrawing.SetVariable "DIMCLRE", acByLayer
    ThisDrawing.SetVariable "DIMCLRT", acByLayer
    Next DimSt
    ThisDrawing.SendCommand ("Dim" & vbCr & "Update" & vbCr & "All" &
    vbCr & vbCr & "Exit" & vbCr)

    End Sub
     
    Jason Smith, Feb 18, 2004
    #1
  2. On a different note, why not just use a script file if you are stuck.
    There is nothing you are doing that can't be done, and maybe better,
    with a script and ScriptPro [download from adesk website under migration
    tools]

    Just a thought to keep you moving...
    ___________________________
    Mike Tuersley
    CADalyst's AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Feb 18, 2004
    #2
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.