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

图片说明

2个回答

AutoCAD的二次开发大致有两种方式:一种是需要AutoCAD的运行环境,另外一种是可脱离AutoCAD的运行环境

qq_42861135
qq_42861135 回复qq_37035042: 兄弟能不能只获取选中部分的实体
8 个月之前 回复
qq_37035042
qq_37035042 CAD二次开发获取当前数据库所有实体,怎么弄
一年多之前 回复
  操作多行文本, 导出多行文本的内容到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();
                }

            }




        }
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!