Author Topic: Is it possible to insert wmf into drawing using OpenFileDialog?  (Read 3359 times)

0 Members and 1 Guest are viewing this topic.

Proctor

  • Guest
Hello: I would like to allow the user to use the openFileDialog to select a windows metafile (wmf) of their choice and insert into a drawing. I searched all the wmf, insert, import ...etc. on this site to try and find how I can do this...but was unable to find solution.

Has anyone done anything like this before?

Here's the code I use to open a drawing..it's not happy when i try it w/ a wmf.

Code: [Select]
Public Sub OpenWMF()

        Dim myFileDialog As New System.Windows.Forms.OpenFileDialog()
        'Dim myFileDialog As New System.Windows.Forms.OpenFileDialog()
        myFileDialog.Filter = "Image Vector files|*.wmf"
        Dim myDiagResult As System.Windows.Forms.DialogResult
        myDiagResult = myFileDialog.ShowDialog()

        Dim doc As Document
        doc = Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor
        ed = doc.Editor

        If myDiagResult = System.Windows.Forms.DialogResult.OK Then
            Try
                Dim myFile As String

                myFile = myFileDialog.FileName.ToString()

[color=red]'bombs on this line:[/color]
                Application.DocumentManager.Open(myFile.ToString(), False)

                Application.DocumentManager.MdiActiveDocument.LockDocument(DocumentLockMode.AutoWrite, Nothing, Nothing, True)
                'if the drawing is saved so that paperspace was showing, this code makes sure that model space is the default setting for the user to see.
                ApplicationServices.Application.SetSystemVariable("TileMode", 1)
                Me.Close()
            Catch ex As Autodesk.AutoCAD.Runtime.Exception
                MsgBox(ex.Message)
            End Try
        End If

    End Sub

any dirrection is truly appreciated.
Thanks,
proctor

Glenn R

  • Guest
Re: Is it possible to insert wmf into drawing using OpenFileDialog?
« Reply #1 on: April 21, 2008, 05:15:30 PM »
'bombs on this line:
                Application.DocumentManager.Open(myFile.ToString(), False)

Helloooo: Hmmm...well...

Application - the AutoCAD progam itself.
DocumentManager - The AutoCAD program's DRAWING/Database manager (i.e. the drawing windows you have open)
Open - the AutoCAD programs Document Management system's way of opening another DRAWING....

...no wonder you can't Open a .WMF file as AutoCAD opens .DWG (Drawing) files.

As far INSERTING a .WMF file goes, I don't think you can even do this through attaching a raster image, but I may be mistaken.

Proctor

  • Guest
Re: Is it possible to insert wmf into drawing using OpenFileDialog?
« Reply #2 on: April 21, 2008, 05:30:41 PM »
makes sense...thanks for setting me straight. -it works similar performing a file -> open via the toolbar. it only allows for drawings to be opened. 

I sure hope that it's possible to do this somehow....
 :cry:

thanks again,
Proctor

Glenn R

  • Guest
Re: Is it possible to insert wmf into drawing using OpenFileDialog?
« Reply #3 on: April 21, 2008, 05:39:00 PM »
As I said, I don't think you can do this even as a RASTER image attach...have a look at the command WMFIN...

Antisthenes

  • Guest
Re: Is it possible to insert wmf into drawing using OpenFileDialog?
« Reply #4 on: April 21, 2008, 05:59:26 PM »
I use InkScape http://www.inkscape.org/ to open WMF files and Rhinoceros to save them if that helps?


hendie

  • Guest
Re: Is it possible to insert wmf into drawing using OpenFileDialog?
« Reply #5 on: April 22, 2008, 03:52:19 AM »
now if only you could get Rhinoceros to run inside of AutoCAD all would be sweet

can it do that ? it seems to be able to do everything else

Proctor

  • Guest
Re: Is it possible to insert wmf into drawing using OpenFileDialog?
« Reply #6 on: April 22, 2008, 10:32:58 AM »
I apologize for just getting back -  Antisthenes, are you saying that inkscape will allow me to automate opening my wfm files into autocad?

Thanks,
Proctor

Proctor

  • Guest
Re: Is it possible to insert wmf into drawing using OpenFileDialog?
« Reply #7 on: April 22, 2008, 01:03:00 PM »
Hello: I took Glen's suggestion and looked at the WMFIN command - in conjunction with Kean Welmsley's post showing how i could call my command:

http://through-the-interface.typepad.com/through_the_interface/2006/08/calling_command.html

Code: [Select]
Public Shared Sub OpenWmf()
        Dim doc As Autodesk.AutoCAD.ApplicationServices.Document
        doc = Application.DocumentManager.MdiActiveDocument
        doc.SendStringToExecute("_WMFIN" & ControlChars.CrLf, False, False, False)
End Sub


It works great! Thanks all for your posts. Thanks Glen for your suggestion.