| Author |
Message |
weslleywang
Guest
|
Posted:
Wed Mar 23, 2005 3:22 am Post subject:
check if in zero document state |
|
|
Hi:
I am working on a layer state management routine. I like to know when autocad is in zero document state, so I can disable all the control in my form. since there are no ThisDrawing, how I can get the AcadApplication? I am going to play with GetObject, GetInterfaceObject. If anyone can give me a right direction, I will appreciate a million.
thank you,
Wes
|
|
| Back to top |
|
 |
Frank Oquendo
Guest
|
Posted:
Wed Mar 23, 2005 3:28 am Post subject:
Re: check if in zero document state |
|
|
weslleywang wrote:
| Quote: | I like to know when autocad is in zero document state
|
Can a VBA macro be run in ZDS? |
|
| Back to top |
|
 |
weslleywang
Guest
|
Posted:
Wed Mar 23, 2005 8:40 pm Post subject:
Re: check if in zero document state |
|
|
Hi Frank:
My routine is a modeless dialog box with a toolbar and a couple of buttons. my plan is, it should work in the case, you switch from 1 doc to another, close a doc, open a new doc. In the case of close doc, my routine will keep running so it could be in the ZDS. this is the reason I am asking.
Thank you,
Wes
|
|
| Back to top |
|
 |
Jackrabbit
Guest
|
Posted:
Wed Mar 23, 2005 9:14 pm Post subject:
Re: check if in zero document state |
|
|
In Delphi but you should be able to adapt it:
| Code: |
unit Unit1;
interface
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
ComObj,
StdCtrls,
AutoCAD_TLB;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//------------------------------------------------------------------------------
procedure ConnectToAcad(var Acad: AcadApplication);
var
Msg: string;
begin
try
Acad := IDispatch(GetActiveOleObject('AutoCAD.Application.16')) as
AcadApplication;
if not Acad.Visible then
begin
Acad.Visible := True;
end;
except
try
Acad := IDispatch(CreateOleObject('AutoCAD.Application.16')) as
AcadApplication;
Acad.Application.WindowState := acMax;
Acad.Visible := True;
except
Msg := 'Could not establish a connection to AutoCAD.';
ShowMessage(Msg);
Exit;
end;
end;
end;
//------------------------------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
Acad: AcadApplication;
DocCount: Integer;
begin
ConnectToAcad(Acad);
DocCount := Acad.Application.Documents.Count;
Edit1.Text := IntToStr(DocCount);
Acad := nil;
end;
//------------------------------------------------------------------------------
end.
|
|
|
| Back to top |
|
 |
Maksim Sestic
Guest
|
Posted:
Thu Mar 24, 2005 12:04 am Post subject:
Re: check if in zero document state |
|
|
Wes, take care when in ZDS. It's very hard to implement from VBA, and I
guess ObjectARX is the only solution. My idea was to prevent an user getting
into a ZDS by using ACAD's Events mechanisms, but few Autodesk's verticals
sometimes "disagree" with my approach (Map 3D 2005, for example... in rare
cases it throws an exception). Now, I had a very good reason for preventing
a ZDS - I couldn't kill ZDS menus from VBA (there's no localized ACAD for my
country)... what's yours?
Regards,
Maksim Sestic
"weslleywang" <nospam@address.withheld> wrote in message
news:3622355.1111592462501.JavaMail.jive@jiveforum1.autodesk.com...
| Quote: | Hi Frank:
My routine is a modeless dialog box with a toolbar and a couple of
buttons. my plan is, it should work in the case, you switch from 1 doc to |
another, close a doc, open a new doc. In the case of close doc, my routine
will keep running so it could be in the ZDS. this is the reason I am asking.
|
|
| Back to top |
|
 |
|
|
|
|