airtreeyang 发表于 2008-3-14 16:12:00

c#中如何插入多行文本?谢谢

我想实现cad多行文本的功能,指定多行文本顶端和末端的位置,然后设置字体大小,对齐方式.然后输入要显示的字,高手们这个能指点一下,吗?帮点小忙吧,小弟在次谢过了!

bluelightcsy 发表于 2008-3-16 16:12:00

C++的话,AcDbMText,至于C#找一下SDK对应的类,new出来,设置一下参数,加入数据库就行了,应该不难。

airtreeyang 发表于 2008-3-18 09:57:00

<p>谢谢我知道了 </p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 19.2pt; mso-pagination: widow-orphan;">Database db = Application.DocumentManager.MdiActiveDocument.Database;<br/>DBTransMan tm = db.TransactionManager;<br/><br/>MText txt = new MText();<br/>txt.Contents = "123\r\n456\r\n测试<span lang="EN-US">";<br/>using(Transaction ta = tm.StartTransaction())<br/>{<br/>&nbsp; &nbsp; &nbsp; &nbsp; BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId, OpenMode.ForRead);<br/>&nbsp; &nbsp; &nbsp; &nbsp; ObjectId objid;<br/>&nbsp; &nbsp; &nbsp; &nbsp; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;<br/>&nbsp; &nbsp; &nbsp; &nbsp; if (bt.Has("A010001"))<br/>&nbsp; &nbsp; &nbsp; &nbsp; {<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objid = bt["A010001"];<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockTableRecord btr = (BlockTableRecord)tm.GetObject(objid, OpenMode.ForWrite);<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; btr.AppendEntity(txt);<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tm.AddNewlyCreatedDBObject(txt, true);<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ed.WriteMessage(btr.Name + " --- Renaud");<br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ta.Commit();<br/>&nbsp; &nbsp; &nbsp; &nbsp; } <br/>&nbsp; &nbsp; &nbsp; &nbsp; else <br/>&nbsp; &nbsp; &nbsp; &nbsp; {<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ed.WriteMessage("Not Has --- Renaud");<br/>&nbsp; &nbsp; &nbsp; &nbsp; }<br/>}<p></p></span></p><p></p>
页: [1]
查看完整版本: c#中如何插入多行文本?谢谢