.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Stuck Mainwindow.visible

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
352 Views, 5 Replies

Stuck Mainwindow.visible

Hey, any help would be appreciated, I can seem to open a window here's the code


Dim Acadapp As Autodesk.AutoCAD.ApplicationServices.Application
Acadapp = CreateObject("AutoCAD.Application")
Acadapp.DocumentManager.Open("c:\test.dwg", True, "null")
Acadapp.MainWindow.Visible = True
Acadapp.DocumentManager.MdiActiveDocument.CloseAndSave("bob.dwg")
Acadapp.Quit()
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

What help you need? What is the problem?

Why you use CreateObject to create
Autodesk.AutoCAD.ApplicationServices.Application object? If your .NET API
app runs, the object is there already, since Acad is running. Or your code
is in a stand-alone application? if yes, then you cannot use ObjectAXR .NET
API, that is, there is no Autodesk.AutoCAD.ApplicationServices.Application
object available to use in stand-alone VB.ENT app.


wrote in message news:5651062@discussion.autodesk.com...
Hey, any help would be appreciated, I can seem to open a window here's the
code


Dim Acadapp As Autodesk.AutoCAD.ApplicationServices.Application
Acadapp = CreateObject("AutoCAD.Application")
Acadapp.DocumentManager.Open("c:\test.dwg", True, "null")
Acadapp.MainWindow.Visible = True
Acadapp.DocumentManager.MdiActiveDocument.CloseAndSave("bob.dwg")
Acadapp.Quit()
Message 3 of 6
Anonymous
in reply to: Anonymous

Ok here's what i'm trying to do,

open a drawing then run a check and then shut it down..
the code provided does start acad.exe..I can't seem to make it visible or close it after it starts..

I'm trying this now but seem stuck on this I'm missing something;

However, you can do the same task using the .NET managed API. The Open method of the DocumentCollection class(DocumentManager property of the Application object) and CloseAndDiscard method of the Document class can be used for opening & closing without saving operations respectively.

Dim docs As DocumentCollection
docs = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
Try
docs.Open("C:\test.dwg", False, "")
Catch Ex As System.Exception
MessageBox.Show(Ex.ToString)
End Try
Message 4 of 6
Anonymous
in reply to: Anonymous

Why do you need to start acad.exe? Shouldn't it be running before your code
can run (inside Acad, as ObjectARX .NET API application)?

Again, if your app is a stand-alone VB.NET app (you did not say, but it
seems so, to me), then you CANNOT use ObjectARX .NET API. Period.


wrote in message news:5651450@discussion.autodesk.com...
Ok here's what i'm trying to do,

open a drawing then run a check and then shut it down..
the code provided does start acad.exe..I can't seem to make it visible or
close it after it starts..

I'm trying this now but seem stuck on this I'm missing something;

However, you can do the same task using the .NET managed API. The Open
method of the DocumentCollection class(DocumentManager property of the
Application object) and CloseAndDiscard method of the Document class can be
used for opening & closing without saving operations respectively.

Dim docs As DocumentCollection
docs =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
Try
docs.Open("C:\test.dwg", False, "")
Catch Ex As System.Exception
MessageBox.Show(Ex.ToString)
End Try
Message 5 of 6
Anonymous
in reply to: Anonymous

Lets try to gets this to work inside..I've created a class command called qar the idea is to launch a select file dialog then run the check. What I have run into, is "eNoDocument" with this code when I use a form, i can get this to work as a class using this preset code but I'm still trying to figure how to show the select dialog in a class.

im docs As DocumentCollection
docs = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
Dim doc As Document
Dim strNamesOfDocs As String
strNamesOfDocs = "These docs were closed" & vbCr
Try

For Each doc In docs
strNamesOfDocs = strNamesOfDocs + doc.Name() & vbCr
doc.CloseAndDiscard()
Next
System.Windows.Forms.MessageBox.Show(strNamesOfDocs)
docs.Open("C:\test.dwg", False)
Catch Ex As System.Exception
System.Windows.Forms.MessageBox.Show(Ex.ToString)
End Try

I've been having a mental block for the last few days and nothing seems to want to work for me ..
Message 6 of 6
Anonymous
in reply to: Anonymous

This was a stupid mistake modaldialog...should be modeless..

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost