.NET

.NET

Reply
Contributor
karea
Posts: 25
Registered: ‎01-27-2011
Message 1 of 5 (232 Views)
Accepted Solution

Batch process and transaction not declared..

232 Views, 4 Replies
07-02-2013 05:20 AM

Hi:

I have a command to open some dwg files and print them. I´m using the Sub imprimePDF. When I did the code with (AutoCAD 2011 and VS 2008) , it runs ok but now it´s wrong.

This is the sub

Sub imprimePDF()
   Dim myDWG As Autodesk.AutoCAD.ApplicationServices.Document
   myDWG = Application.DocumentManager.MdiActiveDocument
   Application.SetSystemVariable("BACKGROUNDPLOT", 0)
   Using tr As Transaction =   Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction()
   Try
       Dim layMgr As LayoutManager = LayoutManager.Current
      Dim loObjId As ObjectId = layMgr.GetLayoutId(layMgr.CurrentLayout)
      Dim lo As Layout = DirectCast(tr.GetObject(loObjId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead), Layout)    error!
.........

end try

.........

end using

...

end sub

 

When I´m debugging the code, last sentence produces an error: 'tr not declared'  and I don't know why.

any ideas?

thanks

Actually this is a different issue...

 

It means that the Transaction and the Layout are not from the same Document.

ADN Support Specialist
augusto.goncalves
Posts: 390
Registered: ‎04-30-2009
Message 2 of 5 (198 Views)

Re: Batch process and transaction not declared..

07-03-2013 06:39 AM in reply to: karea

The code seems ok, so I'm guessing is something with VS

 

Can you share a print-screen of VS when the error happens?

Regards,



Augusto Goncalves
Autodesk Developer Network
Contributor
karea
Posts: 25
Registered: ‎01-27-2011
Message 3 of 5 (191 Views)

Re: Batch process and transaction not declared..

07-03-2013 07:17 AM in reply to: augusto.goncalves

here's the display shows,

 

thanks,

ADN Support Specialist
augusto.goncalves
Posts: 390
Registered: ‎04-30-2009
Message 4 of 5 (187 Views)

Re: Batch process and transaction not declared..

07-03-2013 07:20 AM in reply to: karea

Actually this is a different issue...

 

It means that the Transaction and the Layout are not from the same Document.

Regards,



Augusto Goncalves
Autodesk Developer Network
Contributor
karea
Posts: 25
Registered: ‎01-27-2011
Message 5 of 5 (174 Views)

Re: Batch process and transaction not declared..

07-03-2013 08:52 AM in reply to: augusto.goncalves

ok!, I've erased the green code and added the blue one and  it runs!

 

 Dim docMgr As DocumentCollection = Application.DocumentManager
 

Application.SetSystemVariable("BACKGROUNDPLOT", 0)
        'Using tr As Transaction = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction()
        Using tr As Transaction = docMgr(1).TransactionManager.StartTransaction()

 Try
                Dim layMgr As LayoutManager = LayoutManager.Current
                Dim loObjId As ObjectId = layMgr.GetLayoutId(layMgr.CurrentLayout)
                Dim lo As Layout = DirectCast(tr.GetObject(loObjId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead), Layout)
                Dim ps As New PlotSettings(False)
................

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.