.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Using COM and 2010 to batch plot drawings
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
471 Views, 2 Replies
03-25-2010 05:18 AM
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.acPa perSpace
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
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
acadApp.Documents.Open(CStr(DrawingList.Items.Item
ThisDrawing = acadApp.ActiveDocument 'make this drawing current
ThisDrawing.ActiveSpace = Autodesk.AutoCAD.Interop.Common.AcActiveSpace.acPa
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
Re: Using COM and 2010 to batch plot drawings
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-26-2010 07:41 AM in reply to:
CiDScoop
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.
So... my suggestiong would be to try this:
ThisDrawing = acadApp.Documents.Open(CStr(DrawingList.Items.Item
And removing the other ThisDrawing assignment.
Re: Using COM and 2010 to batch plot drawings
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-29-2010 12:53 AM in reply to:
CiDScoop
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
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
