- namespace JoinBoxAcad.天正;
- public class 天正例子
- {
- [DllImport("tch_kernal.arx", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl,
- EntryPoint = "?SetText@TDbSymbElevation@@QEAAXPEB_W@Z")]
- static extern void TDbSymbSetText(IntPtr tchElev, string txtHigth);
- // 天正文字修改
- [CommandMethod(nameof(Tz_text))]
- public static void Tz_text()
- {
- var dm = Acap.DocumentManager;
- var doc = dm.MdiActiveDocument;
- var db = doc.Database;
- var ed = doc.Editor;
- var entRes = ed.GetEntity("选择竖向值: \n");
- if (entRes.Status != PromptStatus.OK)
- return;
- db.Action(tr => {
- var entTchElev = entRes.ObjectId.ToEntity(tr);
- if (entTchElev is null)
- return;
- TDbSymbSetText(entTchElev.UnmanagedObject, "3.5");
- entTchElev.DowngradeOpen();
- entTchElev.Dispose();
- });
- }
- [DllImport("tch_kernal.arx", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl,
- EntryPoint = "?GetText1@TDbSymbMultiLeader@@QEBAPEB_WXZ")]
- static extern string GetText1(IntPtr tchElev);
- // 天正引线
- [CommandMethod(nameof(Tz_Le))]
- public static void Tz_Le()
- {
- var doc = Acap.DocumentManager.MdiActiveDocument;
- var ed = doc.Editor;
- var db = doc.Database;
- var entRes = ed.GetEntity("选择引出标注: \n");
- if (entRes.Status != PromptStatus.OK)
- return;
- string? text = null;
- db.Action(tr => {
- var entTchElev = entRes.ObjectId.ToEntity(tr);
- if (entTchElev is null)
- return;
- text = GetText1(entTchElev.UnmanagedObject);
- entTchElev.DowngradeOpen();
- entTchElev.Dispose();
- });
- if (text is not null)
- ed.WriteMessage(text);
- }
- }
|