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

Using COM and 2010 to batch plot drawings

2 REPLIES 2
Reply
Message 1 of 3
Colin_Dodds
702 Views, 2 Replies

Using COM and 2010 to batch plot drawings

I have a programme I used for batch plotting using COM which works with 2006 and 2008, but now I have switched to 64 bit 2010 and it just won't work. I can get autocad to open up but not to open a drawing. The code to open is:
Public Function CDOpen() As Boolean 'return value
Dim ThisDrawing As Autodesk.AutoCAD.Interop.AcadDocument
Dim acadApp As Autodesk.AutoCAD.Interop.AcadApplication

Try
'WriteLogFile(ControlChars.CrLf & "Start Autocad")
'start a new autocad session, does not check to see if
'there is any other sessions already

acadApp = New Autodesk.AutoCAD.Interop.AcadApplication 'start a new autocad session
acadApp.Visible = True 'show it

ThisDrawing = acadApp.ActiveDocument 'make the current drawing as active
SDIVariable = CInt(ThisDrawing.GetVariable("sdi"))
ThisDrawing.SetVariable("sdi", 0) 'set MDI mode (set SDI off) to enable drawing to be opened as readonly
ThisDrawing.SetVariable("backgroundplot", 0)
ThisDrawing.Close(False) 'close current drawing and don't save changes (False)

Dim i As Integer

For i = 0 To DrawingList.Items.Count - 1

BorderSize = ""

DrawingPathName = Path.GetDirectoryName(DrawingList.Items.Item(i))
DrawingFileName = Path.GetFileNameWithoutExtension(DrawingList.Items.Item(i))

acadApp.Documents.Open(CStr(DrawingList.Items.Item(i)), True) 'open drawing as Read Only = True
ThisDrawing = acadApp.ActiveDocument 'make this drawing current
ThisDrawing.ActiveSpace = Autodesk.AutoCAD.Interop.Common.AcActiveSpace.acPaperSpace

I drag and drop the drawings onto a list box.

I believe I have everything set up for 64 bit but cannot get a drawing to open.

Am I missing something obvious?

I have also noticed that COM is not the way to go, so what is the right way using .net, Transactions? NETLOAD? SensCommand?

I would really like to get my COM version running again before I take the time to re-write it the new/better way

Thanks for any help

Colin Edited by: colin.dodds on Mar 25, 2010 12:22 PM
2 REPLIES 2
Message 2 of 3
fyathyrio8
in reply to: Colin_Dodds

I have dealt with C#, but not VB with AutoCAD. As a thought, see what acadApp.Documents.Open(CStr(DrawingList.Items.Item(i)), True) returns. It should return an AcadDocument...

So... my suggestiong would be to try this:

ThisDrawing = acadApp.Documents.Open(CStr(DrawingList.Items.Item(i)), True) 'open drawing as Read Only = True

And removing the other ThisDrawing assignment.
Message 3 of 3
Colin_Dodds
in reply to: Colin_Dodds

Thanks for the suggestion, cut the whole thing down to open a drawing, nothing else.
It never gets to the open part and seems to think once autocad is open that's it.

Try
'WriteLogFile(ControlChars.CrLf & "Start Autocad")
'start a new autocad session, does not check to see if
'there is any other sessions already

acadApp = New Autodesk.AutoCAD.Interop.AcadApplication 'start a new autocad session
acadApp.Visible = True 'show it

ThisDrawing = acadApp.ActiveDocument 'make the current drawing as active

acadApp.Documents.Open("c:\test\drawing1.dwg, True) 'open drawing as Read Only = True

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