zoukankan      html  css  js  c++  java
  • arx 在不打开文件的情况下添加带属性的块的问题

    arx 在不打开文件的情况下添加带属性的块,块的对齐方式总是左对齐, 只有在打开文件的情况下是正确的,需要加如下语句:

                HostApplicationServices.WorkingDatabase = db;

    //完整的函数如下

     /// <summary>
            
    /// 批量处理图纸 自已选择得到文件路径列表的
            
    /// </summary>
            
    /// <param name="cationOpenDlg">打开窗口的cation</param>
            
    /// <param name="cationWait">等待窗口的cation</param>
            
    /// <param name="DwgOp">处理函数,使用委托</param>
            public static void SetDwgsData(string cationOpenDlg, string cationWait, string msgFinish, DelegateSet Op)
            {
                System.Windows.Forms.FolderBrowserDialog dlg 
    = new System.Windows.Forms.FolderBrowserDialog();
                
    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return;
                
    string dicPath = dlg.SelectedPath;
                
    if (dicPath == ""return;

                List
    <string> files = new List<string>(); //路径字符串列表
                GetFileList(dicPath, files);

                
    using (frmWaiting frm = new frmWaiting())
                {
                    frm.Count 
    = files.Count;
                    frm.Fun 
    = cationWait;
                    Application.ShowModelessDialog(frm);
                    System.Windows.Forms.Application.DoEvents(); 
    //释放CPU控制权;

                    
    if (Application.DocumentManager.Count == 0) Application.DocumentManager.Add("acadiso.dwt");
                    Document doc 
    = Application.DocumentManager.MdiActiveDocument;
                    DocumentLock lockDoc 
    = doc.LockDocument();
                    
    using (lockDoc)
                    {
                        
    //打开图形数据库db 多张图纸时使用
                        int i = 0;
                        
    foreach (string fileName in files)
                        {
                            frm.Index 
    = ++i;
                            frm.FileName 
    = fileName;
                            System.Windows.Forms.Application.DoEvents();
                            frm.Update();
                            Database db 
    = ArxHlb.CADEntAdd.Getdb(fileName, System.IO.FileShare.ReadWrite, false);
                            HostApplicationServices.WorkingDatabase 
    = db; //需要置为当前数据库
                            using (Transaction tr = db.TransactionManager.StartTransaction())
                            {
                                BlockTable bt 
    = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
                                BlockTableRecord btr 
    = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                                Op(db, tr, bt, btr);
    //委托的函数
                                tr.Commit();
                            }
                            db.SaveAs(db.Filename, DwgVersion.Current);
                        }
                    }
                    HostApplicationServices.WorkingDatabase 
    = doc.Database;//需要还原,否则打开出错
                }
                SWF.MessageBox.Show(msgFinish);
            }
  • 相关阅读:
    在c#中使用全局快捷键
    把其他C/C++编译器集成到VC2005中
    零基础学习Oracle 10G视频教程
    异常处理 Exception
    序列化与反序列化 BinaryFormatter二进制(.dat)、SoapFormatter(.soap)、XmlSerializer(.xml)
    MVC 数据验证
    MVC 路由规则
    分部类,分部方法 修饰符partial
    HttpRuntime类
    MVC 模型绑定
  • 原文地址:https://www.cnblogs.com/houlinbo/p/1682674.html
Copyright © 2011-2022 走看看