Code Red > VB(A)

AcadApplication.Visible = False

(1/4) > >>

Keith™:
Ok.... here is my dilemna....

I am busy putting together an application in VB that will access the AutoCAD object model and perform a series of tasks with AutoCAD...

IF AutoCAD is running I will leave the AcadApplication visible, but if the application is not already running I would like to have the application invisible therefore hidden from the users view.

I need to know what hoops I need to jump through (and if it is indeed possible) to manipulate a drawing while the application is hidden.

For example... Does anyone know how I can do this:

--- Code: ---
AcadApplication.Visible = False
AcadApplication.ActiveDocument.ModelSpace.AddLine PT1, PT2
AcadApplication.ActiveDocument.Close True
AcadApplication.Quit

--- End code ---

Ron Heigh:
I added an OLE ACAD object to my form called "oleDWG"

Then I did this:


--- Code: ---Private Sub Form_Load()
 
  'initialize dummy AutoCAD session
    oleDwg.DoVerb 0
    oleDwg.DoVerb -3
   
    'display the main form
    frmMain.Show
   
    'set the autocad object
    Set Acad = GetObject(, "AutoCAD.Application.15")

etc....
--- End code ---


Using this route, I can edit the drawing as you want, but I haven't tried to add lines and such, just purge.

HTH

Keith™:
Ron, this is what I use to grab the Acad session, if it exists, if not it creates it. The cool thing about using this code without the .15 versioning is that it will work with any version of AutoCAD.


--- Code: ---
Function GetAcadObject() As Object
 On Error Resume Next
 Set GetAcadObject = GetObject(, "AutoCAD.Application")
    If Err <> 0 Then
        Err.Clear
        Set GetAcadObject = CreateObject("AutoCAD.Application")
        If Err <> 0 Then
            MsgBox "Could not load or find AutoCAD.", vbExclamation
            End
        End If
    End If
End Function

--- End code ---


I'll look into the OLE thing, but I might run into problems with versioning if I have to reference the type libraries at design time.

hendie:
I don't know if this has any relevance but I just tried it using an excel workbook.
I could create the application, manipulate cells by sending info from autocad and printout a worksheet all while keeping it invisible

Keith™:
I know you can do it in Excel, because it uses a different mthod of accessing it's data. AutoCAD uses graphical coordinates to manipulate its database. The main reason I am asing is because I have yet to be able to manipulate the AutoCAD model from outside AutoCAD with the AutoCAD window not being the topmost and active window.

Navigation

[0] Message Index

[#] Next page

Go to full version