qq_37035042 2018-05-18 03:56 采纳率: 20%
浏览 2887
已结题

CAD二次开发我已经获取到视图上所有实体id,怎么对这些实体进行操作

图片说明

  • 写回答

3条回答 默认 最新

  • lionmxs 2018-08-13 08:14
    关注
      操作多行文本, 导出多行文本的内容到word2007
    
            int co;
         string[] ct;
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            TypedValue[] acval = new TypedValue[2];
            acval.SetValue(new TypedValue((int)DxfCode.LayerName, "校审"), 0);
            acval.SetValue(new TypedValue((int)DxfCode.Start, "MTEXT"), 1);
            using (doc.LockDocument())
            {
    
                using (Transaction tran = db.TransactionManager.StartTransaction())
                {
                    wordapp = new Msword.ApplicationClass();
                    wordapp.DisplayAlerts = Msword.WdAlertLevel.wdAlertsNone;
    
                    wordapp.Visible = true;
                    object missing = System.Reflection.Missing.Value;
                    string path = "D:\\model\\model.doc";
                    object templatename = path;
                    object dir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\桌面.doc";
                    //   worddoc = wordapp.Documents.Add(ref templatename, ref missing, ref missing, ref missing);
    
    
                    //  path = Environment.CurrentDirectory + "\\demo.doc";
    
                    object format = Msword.WdSaveFormat.wdFormatDocument;
    
    
                    worddoc = wordapp.Documents.Add(ref templatename, ref missing, ref missing, ref missing);
                    SelectionFilter Self = new SelectionFilter(acval);
                  //  PromptSelectionOptions pso = new PromptSelectionOptions();
    
                    PromptSelectionResult PR = ed.GetSelection(Self);
                    if (PR.Status == PromptStatus.OK)
                    {
                        SelectionSet aset = PR.Value;
                        co = aset.Count;
                        ObjectId[] oid = aset.GetObjectIds();
    
                        ct = new string[co];
                        for (int i = 0; i < co; i++)
                        {
                            MText mt = (MText)tran.GetObject(oid[i], OpenMode.ForRead);
                            ct[i] = mt.Text;
                            worddoc.Paragraphs.Last.Range.Text += ct[i];
    
                        }
                    }
    
                        worddoc.SaveAs(ref dir, ref format, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                    //}
                    tran.Commit();
                    }
    
                }
    
    
    
    
            }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题