+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12
  1. #11
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,940

    Default

    Registered forum members do not see this ad.

    I just remembered you're attempting to write an Application outside of AutoCAD... The code being referenced (from the developer help) assumes you are coding a plug-in to load/run within AutoCAD.
    "Potential has a shelf life." - Margaret Atwood

  2. #12
    Forum Newbie
    Using
    Map 3D 2010
    Join Date
    Aug 2008
    Posts
    8

    Default

    Registered forum members do not see this ad.

    This is a File Manager Applicatio which clients reference an index of documents stored in an Access mdb file. The app allows them to check out, check in or copy files. If a client attempts to check in a file that is open in Autocad he/she receives a message from the app to save and close the file first. This only checks to see if the file is open. It does nothing inside of Autocad or to the file.

    Here is the VB6 code for this function.
    Code:
    Public Function AcadLink() As Boolean
      Dim i As Integer
      Dim DwgName As String
      Dim hWndMain As Long
      Dim appverfile As String
      Dim lstItem As String
      Dim strappver As String
     
      AcadLink = False
      On Error GoTo nocad
      Set AcadApp = GetObject(, "AutoCAD.Application")
    '  Debug.Print AcadApp.Name
    '  Debug.Print AcadApp.FullName
    '  Debug.Print AcadApp.hWnd
    '  Debug.Print AcadApp.Caption
    '  MsgBox ("*" & AcadApp.Caption & "*"), vbOKOnly
     
      Set fso = CreateObject("Scripting.FileSystemObject")
      appverfile = strAppPath & "ClientAutoCadVersion.rpt"
      If bFileExists(appverfile) Then
        Open appverfile For Input As #filenum
        Do
          Input #filenum, lstItem
          If UCase(lstItem) = UCase(Left(AcadApp.Caption, Len(lstItem))) Then
            strappver = Left(AcadApp.Caption, Len(lstItem))
          End If
        Loop Until EOF(filenum)
        Close #filenum
        DoEvents
      End If
     
      If Len(strappver) = 0 Then
        appverfile = "\\networkplace\ClientAutoCadVersion.rpt"
        If bFileExists(appverfile) Then
          strappver = Left(AcadApp.Caption, InStr(1, AcadApp.Caption, "[") - 4)
          Open appverfile For Append As #filenum
          Print #filenum, strappver
          Close #filenum
          DoEvents
          filea = strAppPath & "ClientAutoCadVersion.rpt"
          fileb = "\\networkplace\ClientAutoCadVersion.rpt"
          FileUpdate
          DoEvents
        End If
      End If
     
      appverfile = strAppPath & "ClientAutoCadVersion.rpt"
      If bFileExists(appverfile) Then
        Open appverfile For Input As #filenum
        Do
          Input #filenum, lstItem
          hWndMain = FindWindow(vbNullString, lstItem & " - [" & lstCitem & ".dwg]")
          If hWndMain > 0 Then
            AcadLink = True
            Close #filenum
            DoEvents
            GoTo nocad
          End If
        Loop Until EOF(filenum)
      End If
     
      For i = 0 To AcadApp.Documents.Count - 1
        DwgName = Left(Right(AcadApp.Documents(i).Name, Len(lstCitem) + 4), Len(lstCitem))
        If lstCitem = DwgName Then
          AcadLink = True
          Exit For
        End If
      Next i
    nocad:
    End Function

Similar Threads

  1. how to check if CAD is OPEN AND READY
    By inneedofmajorhelp in forum .NET, ObjectARX & VBA
    Replies: 16
    Last Post: 14th Dec 2011, 12:16 am
  2. I need a way to check if a pdf file is open?
    By hemuni in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 27th Jul 2011, 12:42 pm
  3. Check if app already open?
    By Small Fish in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 17th Aug 2009, 09:48 pm
  4. Autocad documents online.
    By gjensen01 in forum Useful Links
    Replies: 3
    Last Post: 27th Oct 2005, 09:40 pm
  5. Open Multiple Instances of AutoCAD version 13
    By cmias in forum AutoCAD Drawing Management & Output
    Replies: 11
    Last Post: 9th Oct 2003, 01:52 pm

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