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);
                    }
                }
    
  • 相关阅读:
    异常问题处理记录(转载篇)
    linux服务器出现大量连接:sshd: root@notty
    第4章 Python运算符
    第2章 python基础知识
    第1章 python环境搭建
    Tomcat漏洞升级
    第3章 数据类型、运算符和表达式
    第2章 C语言基础知识
    第1章 概述
    第1章 企业管理概论
  • 原文地址:https://www.cnblogs.com/myzw/p/12331343.html
Copyright © 2011-2022 走看看