MDI Form

MDI Form

Anonymous
Not applicable
270 Views
5 Replies
Message 1 of 6

MDI Form

Anonymous
Not applicable
hi,everyone
we know A2K is MDI, it can open several documents at same time, but VB app
using automation only can available the active document. the problem is how
to activate other document and do some thing while the app is running?

any ideals?

thanks in advance
Michael
0 Likes
271 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
The AcadDocuments collection of the AcadApplication object gives access to all
open drawings.

Mark Holder

Michael Chen wrote:

> hi,everyone
> we know A2K is MDI, it can open several documents at same time, but VB app
> using automation only can available the active document. the problem is how
> to activate other document and do some thing while the app is running?
>
> any ideals?
>
> thanks in advance
> Michael
0 Likes
Message 3 of 6

Anonymous
Not applicable
mark, thanks for your response. maybe i didn't make it clear.
i don't want to get the document or a object's( a line ...) application
name, i want to do this : after doing something in current active document
then turn to activate another document and do some thing while the app is
running?
0 Likes
Message 4 of 6

Anonymous
Not applicable
From the Visual Basic Help files of VB Design
http://vbdesign.hypermart.net/cadpages/

Hi all,

I would like to expand on that if I may. This is a lttle demo I cooked up
for you based on the thread so far.

If you open a new project add a user form with a command button (keep the
default names, and the location of the button and size of the form do not
matter, this code will set them for you) then paste this into the code
module of the form, you will get a demo of what Mark is saying. What will
this demo do? It adds a option button to the form for every drawing open in
AutoCAD (so you must be set for MDI) then you can select one of the option
buttons (the drawing name is added to its caption) and click the button. the
selected drawing is now active. It should not take much work to translate
this into your application, but if you need help, by all means let me know.

Option Explicit
Private Sub CommandButton1_Click()
Dim objCtl As Control
Dim strName As String
For Each objCtl In UserForm1.Controls
If TypeOf objCtl Is OptionButton Then
If objCtl.Value = True Then
strName = objCtl.Caption
ThisDrawing.Application.Documents.Item(strName).Activate
objCtl.Caption = "Active Document"
End If
End If
Next
ThisDrawing.Application.Update
End Sub
Private Sub UserForm_Initialize()
Dim objDrawing As AcadDocument
Dim ctlCheckBox As OptionButton
Dim intCnt As Integer
CommandButton1.Left = 2
CommandButton1.top = 2
CommandButton1.Caption = "Make Drawing Active"
CommandButton1.Width = 108
CommandButton1.Height = 20
Me.Width = 120
Me.Height = 50
intCnt = 1
For Each objDrawing In ThisDrawing.Application.Documents
UserForm1.Controls.Move 0, 20
intCnt = intCnt + 1
Set ctlCheckBox = UserForm1.Controls.Add("Forms.OptionButton.1", "Option "
& intCnt, True)
ctlCheckBox.Caption = objDrawing.Name
ctlCheckBox.AutoSize = True
Me.Height = Me.Height + 23
Next
End Sub

Randall Rath
VB Design
0 Likes
Message 5 of 6

Anonymous
Not applicable
Michael,

I think I understood your question. Here is som code to show what I mean:

In the ACAD session, there are 2 open drawings, "A", and "B". Drawing "A" is
active.

Dim dwgB as AcadDocument

On Error Resume Next
Set dwgB = myAcad.Documents("B")
If Err = 0 then
dwgB.Activate
' do stuff with dwgB here ...
endif

Michael Chen wrote:

> mark, thanks for your response. maybe i didn't make it clear.
> i don't want to get the document or a object's( a line ...) application
> name, i want to do this : after doing something in current active document
> then turn to activate another document and do some thing while the app is
> running?
0 Likes
Message 6 of 6

Anonymous
Not applicable
thank Randall,
your code is very good,and your "a code a day" is also very good.

BTW, i want to batch plot many drawings which pen width connected with its
color( i make a ctb file), i can use "plottofile filename,pc3file" method to
load pc3 file, but i don't know how to load ctb file, can you give me some
sample code. is it only choice to making pen width connected with color?

good lucky!
Michael

Randall Rath wrote in message
news:7u559b$2a09@adesknews2.autodesk.com...
> From the Visual Basic Help files of VB Design
> http://vbdesign.hypermart.net/cadpages/
>
0 Likes