VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Opening Drawings Using VB.Net

4 REPLIES 4
Reply
Message 1 of 5
dhorger
1530 Views, 4 Replies

Opening Drawings Using VB.Net

Hi folks,

I'm trying to open a list of drawings to perform operations on each one, but I've run into a snag. Here's the relevant code:

Dim dm As DocumentCollection = Application.DocumentManager
Dim doc As Autodesk.AutoCAD.ApplicationServices.Document

For x = 0 To lstFiles.Items.Count - 1

' open the drawing
doc = dm.Open(lstFiles.Items(x), ro)

' set the drawing current
dm.MdiActiveDocument = doc

' do stuff...

' close the drawing
doc.CloseAndDiscard()

Next

Here's the snag: when I try to make the most recently opened item the current drawing (using the line in bold), processing of the code stops until I manually set the focus back to the document that was open when I started the function. Once I do that, processing again starts at the next line of code. No errors pop up. What's the proper way to do this so that I can have the drawing that was just opened the current drawing?

Thanks,
Dave Horger
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: dhorger

Hi Dave,

You've posted this to the VBA newsgroup.

You are far more likely to find expertise to resolve your problem in the
.NET newsgroup.


Regards,


Laurie Comerford

dhorger@ieice.com wrote:
> Hi folks,
>
> I'm trying to open a list of drawings to perform operations on each one,
> but I've run into a snag. Here's the relevant code:
>
> Dim dm As DocumentCollection = Application.DocumentManager
> Dim doc As Autodesk.AutoCAD.ApplicationServices.Document
>
> For x = 0 To lstFiles.Items.Count - 1
>
> ' open the drawing
> doc = dm.Open(lstFiles.Items(x), ro)
>
> ' set the drawing current
> *dm.MdiActiveDocument = doc*
>
> ' do stuff...
>
> ' close the drawing
> doc.CloseAndDiscard()
>
> Next
>
> Here's the snag: when I try to make the most recently opened item the
> current drawing (using the line in bold), processing of the code stops
> until I manually set the focus back to the document that was open when I
> started the function. Once I do that, processing again starts at the
> next line of code. No errors pop up. What's the proper way to do this so
> that I can have the drawing that was just opened the current drawing?
>
> Thanks,
> Dave Horger
Message 3 of 5
Anonymous
in reply to: dhorger

You're using the .NET API so the .NET newsgroup is a better place to post.
Repost there rather than reply to this.

If your code is called from a command method, then you need to add the
CommandFlags.Session flag to the CommandMethod attribute.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6239908@discussion.autodesk.com...
Hi folks,

I'm trying to open a list of drawings to perform operations on each one, but
I've run into a snag. Here's the relevant code:

Dim dm As DocumentCollection = Application.DocumentManager
Dim doc As Autodesk.AutoCAD.ApplicationServices.Document

For x = 0 To lstFiles.Items.Count - 1

' open the drawing
doc = dm.Open(lstFiles.Items(x), ro)

' set the drawing current
dm.MdiActiveDocument = doc

' do stuff...

' close the drawing
doc.CloseAndDiscard()

Next

Here's the snag: when I try to make the most recently opened item the
current drawing (using the line in bold), processing of the code stops until
I manually set the focus back to the document that was open when I started
the function. Once I do that, processing again starts at the next line of
code. No errors pop up. What's the proper way to do this so that I can have
the drawing that was just opened the current drawing?

Thanks,
Dave Horger
Message 4 of 5
dhorger
in reply to: dhorger

Thanks! That did the trick.

And I'll remember to post in the .Net newsgroup, next time.

Dave
Message 5 of 5
spesci
in reply to: dhorger

CommandFlags.Session flag to the CommandMethod attribute
Dave,
I don't know where do you put this?
What did you have to put in?

Thanks,
Scott

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

Post to forums  

”Boost