• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Member
    Posts: 3
    Registered: ‎02-01-2010

    Using COM and 2010 to batch plot drawings

    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.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
    Please use plain text.
    Active Contributor
    Posts: 34
    Registered: ‎02-11-2010

    Re: Using COM and 2010 to batch plot drawings

    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.
    Please use plain text.
    Member
    Posts: 3
    Registered: ‎02-01-2010

    Re: Using COM and 2010 to batch plot drawings

    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
    Please use plain text.