+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Forum Newbie
    Using
    AutoCAD 2012
    Join Date
    Jan 2014
    Posts
    2

    Unhappy Trouble With Interop Import Command

    Registered forum members do not see this ad.

    I'm writing a program to import a WMF into the AutoCad Drawing. I haven't been able to find any reference for the import command, so I can't figure out why it's not working. According to Visual Studio, the Import command needs these things to work.

    Code:
    Import(String FileName, Object InsertionPoint, Double ScaleFactor)
    Simplified Code:
    Code:
    Imports Autodesk.AutoCAD.Runtime
    Imports Autodesk.AutoCAD.ApplicationServices
    Imports Autodesk.AutoCAD.DatabaseServices
    Imports Autodesk.AutoCAD.Geometry
    Imports Autodesk.AutoCAD.EditorInput
    Imports Autodesk.AutoCAD.Interop
    
    Dim AcadApp As Autodesk.AutoCAD.Interop.AcadApplication
    AcadApp = CType(GetObject(, "AutoCAD.Application.18.2"), Autodesk.AutoCAD.Interop.AcadApplication)
    acadDoc = AcadApp.ActiveDocument
    
    acadDoc.Import("C:\Users\C\Documents\Drawing1.wmf", New Point3d(2, 2, 0), 2.0)
    When I comment out the last line of code,
    Code:
    acadDoc.Import("C:\Users\C\Documents\Drawing1.wmf", New Point3d(2, 2, 0), 2.0)
    It runs fine.

    The error I'm getting is when I run it AutoCAD,
    Code:
    ************** Exception Text **************
    System.ArgumentException: Value does not fall within the expected range.
       at System.StubHelpers.ObjectMarshaler.ConvertToNative(Object objSrc, IntPtr pDstVariant)
       at Autodesk.AutoCAD.Interop.IAcadDocument.Import(String FileName, Object InsertionPoint, Double ScaleFactor)
       at TestSelectingFiltering.TestSelecting.MyCommands.FilterBlueCircleOnLayer0()
       at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
       at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
       at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
       at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()
    Any help would be greatly appreciated,
    Thanks!

  2. #2
    Forum Newbie
    Using
    AutoCAD 2012
    Join Date
    Jan 2014
    Posts
    2

    Default

    Registered forum members do not see this ad.

    Thanks to norman.yuan, solved it.
    Turns out I need to write the location code like this:

    Dim point(0 To 2) as double
    point(0)=2.0 : point(1)=2.0 : point(2)=0.0
    acadDoc.Import("C:\Users\C\Documents\Drawing1.wmf" , point, 2.0)

Similar Threads

  1. Trouble using 'blockreplace' command
    By Bogbadbob658 in forum AutoCAD General
    Replies: 10
    Last Post: 8th Jan 2014, 01:11 pm
  2. ACAD COM Interop, accessing attributes
    By Ramanujan in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 26th Jun 2010, 07:09 am
  3. assign color to line vb.net with interop
    By geogiac in forum .NET, ObjectARX & VBA
    Replies: 2
    Last Post: 30th May 2010, 04:40 pm
  4. CAD to Max import trouble
    By mynmonic in forum 3D Modelling
    Replies: 2
    Last Post: 17th Mar 2010, 07:41 am
  5. Having trouble w/ L command..pls help!
    By F&W cabinets in forum AutoCAD General
    Replies: 5
    Last Post: 4th Aug 2009, 10:26 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts