diff --git a/src/CADShared/CADShared.projitems b/src/CADShared/CADShared.projitems
index ecde82d7dd6c7315bf25b8ea6c9169a4a6a4e9df..d221b2cb2a1d23effcf32feebfc74a61fb2b989c 100644
--- a/src/CADShared/CADShared.projitems
+++ b/src/CADShared/CADShared.projitems
@@ -40,6 +40,7 @@
+
diff --git a/src/CADShared/ExtensionMethod/Entity/AttributeDefinitionEx.cs b/src/CADShared/ExtensionMethod/Entity/AttributeDefinitionEx.cs
new file mode 100644
index 0000000000000000000000000000000000000000..e60e18156bbec61a889d1a7231a2e0cc91a8c42a
--- /dev/null
+++ b/src/CADShared/ExtensionMethod/Entity/AttributeDefinitionEx.cs
@@ -0,0 +1,22 @@
+namespace IFoxCAD.Cad;
+
+///
+/// 属性文字扩展
+///
+public static class AttributeDefinitionEx
+{
+ ///
+ /// 设置属性为多行文字,并通过委托设置多行文字的属性
+ ///
+ /// 属性对象
+ /// 设置多行文字的委托
+ public static void SetMTextAttribute(this AttributeDefinition attr, Action action)
+ {
+ attr.IsMTextAttributeDefinition = true;
+ var mt = attr.MTextAttributeDefinition;
+ action(mt);
+ attr.MTextAttributeDefinition = mt;
+ attr.UpdateMTextAttributeDefinition();
+ }
+
+}
\ No newline at end of file
diff --git a/src/CADShared/Runtime/Env.cs b/src/CADShared/Runtime/Env.cs
index fd18bc87b102a194ec5b9b5bb30b00a2142acf74..024eb5d45d3f3c49fa1583349ebfeaba8b5fdad8 100644
--- a/src/CADShared/Runtime/Env.cs
+++ b/src/CADShared/Runtime/Env.cs
@@ -469,8 +469,8 @@ public static void SetVar(string varName, object value, bool echo = true)
// TODO: 中望没有测试,此处仅为不报错;本工程所有含有"中望"均存在问题
#if zcad
[System.Security.SuppressUnmanagedCodeSecurity]
- [DllImport("zwcad.exe", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl,
- EntryPoint = "zcedGetEnv")]
+ [DllImport("zwcad.exe", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl,
+ EntryPoint = "?zcedGetEnv@@YAHPEB_WPEA_W_K@Z")]//名称大小写不能换
private static extern int AcedGetEnv(string? envName, StringBuilder returnValue);
[System.Security.SuppressUnmanagedCodeSecurity]
diff --git a/tests/TestShared/TestBlock.cs b/tests/TestShared/TestBlock.cs
index 20baa825524e98a23c29a8e527db295beaa9513e..918dca2d7ae0c19fc18c9111adc921e13aec0b2f 100644
--- a/tests/TestShared/TestBlock.cs
+++ b/tests/TestShared/TestBlock.cs
@@ -287,6 +287,44 @@ public void Test_BlockFiledxf()
}
+
+ [CommandMethod("Test_CreateMTextAttributeBlock")]
+ public void Test_CreateMTextAttributeBlock()
+ {
+
+ using var tr = new DBTrans();
+
+ tr.BlockTable.Add("MTextAttributeBlock",btr =>
+ {
+ btr.Origin = Point3d.Origin;
+ // 创建一个多行文字作为块的一部分
+ var mtext = new MText();
+ mtext.Contents = "默认多行文字内容\n第二行内容\n第三行内容";
+ mtext.Location = new Point3d(0, 0, 0);
+ mtext.Width = 200; // 多行文字宽度
+ mtext.Height = 2.5; // 文字高度
+ btr.AddEntity(mtext);
+
+
+ // 创建属性定义
+ var attrDef = new AttributeDefinition();
+ attrDef.Position = new Point3d(0, -50, 0); // 位置在多行文字下方
+ attrDef.Prompt = "请输入属性值";
+ attrDef.Tag = "ATTR_TAG";
+ attrDef.TextString = "默认属性值";
+ attrDef.Height = 2.5;
+ attrDef.Justify = AttachmentPoint.MiddleCenter; // 居中对齐
+
+ // 设置为多行属性
+ attrDef.SetMTextAttribute(att => att.Width = 100);
+ btr.AddEntity(attrDef);
+ });
+
+ tr.CurrentSpace.InsertBlock(Point3d.Origin, "MTextAttributeBlock");
+
+
+ }
+
[CommandMethod(nameof(Test_ClipBlock))]
public void Test_ClipBlock()