Message 1 of 5
Export the selection entity to wmf file ?

Not applicable
03-26-2014
01:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I try to export the wmf file wilth "Autodesk.AutoCAD.Interop.DLL",I find a trouble
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.PlottingServices; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.Interop; using System.Runtime.InteropServices; [CommandMethod("NewExport")] static public void NewExplort() { Document doc = Application.DocumentManager.MdiActiveDocument; AcadDocument acadDoc = doc.AcadDocument as AcadDocument; string exportFile = null; exportFile = "C:\\Temp\\Test1.wmf"; SelectionSet s1=getVll(); AcadSelectionSet sset=s1 as AcadSelectionSet; //***it is error the sset is null,but the s1 is not null acadDoc.Export(exportFile, "WMF", sset); } static public SelectionSet getVll() { SelectionSet SS = null; Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database; Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; // Entity entity = null; DBObjectCollection entityCollection = new DBObjectCollection(); PromptSelectionResult ents = ed.SelectAll(); if (ents.Status == PromptStatus.OK) { using (Transaction transcation = db.TransactionManager.StartTransaction()) { SS = ents.Value; transcation.Commit(); } } return SS; }
AcadSelectionSet sset=s1 as AcadSelectionSet; // here is error ,the sset is null ,but the s1 is not null?how to modify?