zoukankan      html  css  js  c++  java
  • 论坛中看到的代码,留存备用 批量创建dwg文件

    OpenFileDialog ofd = new OpenFileDialog();
                ofd.Title = "Select PointFiles to import";
                ofd.CheckFileExists = true;
                ofd.Multiselect = true;
                if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return;
                dynamic prefs = Autodesk.AutoCAD.ApplicationServices.Application.Preferences;
                dynamic files = prefs.Files;
                string qnew = files.QNewTemplateFile;
    
                foreach (string file in ofd.FileNames)
                {
                    string path = Path.GetDirectoryName(file);
                    string filename = Path.GetFileNameWithoutExtension(file);
                    string newname = path + "\" + filename + ".dwg";
                    using (Database db = new Database(false, true))
                    {
                        db.ReadDwgFile(qnew, FileOpenMode.OpenForReadAndWriteNoShare, false, "");
                        using (Transaction tr = db.TransactionManager.StartTransaction())
                        {
                            CivilDocument civdoc = CivilDocument.GetCivilDocument(db);
                            ObjectId styleId = civdoc.Styles.SurfaceStyles["TDG - Border Only"];
                            ObjectId surfId = TinSurface.Create(db, filename);
                            TinSurface surf = (TinSurface)surfId.GetObject(OpenMode.ForWrite);
                            PointFileFormatCollection ptFileFormats = PointFileFormatCollection.GetPointFileFormats(db);
                            PointFileFormat ptFormat = ptFileFormats["PNEZD (comma delimited)"];
                            surf.StyleId = styleId;
                            surf.PointFilesDefinition.AddPointFile(file, ptFormat);
                            tr.Commit();
                        }
                        db.SaveAs(newname, DwgVersion.Current);
                    }
                }
    
  • 相关阅读:
    进入社会,我们要做哪些准备?
    2天玩转单反相机(第二讲)
    Google广告优化与工具
    Ext JS 4:模型剖析
    iphone开发教程(1) iOS大纲
    iPhone objectivec字符串类NSString的使用
    Ext JS 4倒计时:图形和图表
    Ext JS 4倒计时:开发者预览版
    WOSA介绍
    “苹果皮”与知识产权
  • 原文地址:https://www.cnblogs.com/myzw/p/12331343.html
Copyright © 2011-2022 走看看