Jump to content
dropoff510

Trouble With Interop Import Command

Recommended Posts

dropoff510

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.

 

Import(String FileName, Object InsertionPoint, Double ScaleFactor)

Simplified 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,

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,

************** 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!:)

Share this post


Link to post
Share on other sites
dropoff510

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)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...