- UID
- 183225
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2004-10-13
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
用的是:C#.NET开发CAD2006;
开始用的是DOTNETARX,文字不能通过text.Position来定位。
后来不用DOTNETARX,改用C#托管类,还是不行。
请知道原因的朋友给我指点一下。
先谢过。
我的代码是这样的:
/// <summary>
/// 插入文字到数据库中(模型空间)
/// </summary>
/// <param name="textstr">加入的文字</param>
/// <param name="position">文字的位置</param>
/// <param name="styleName">文字的样式名称,作为函数TextStyleId的参数</param>
/// <param name="rotation">文字转角</param>
/// <param name="horizontalMode">水平对齐方式:0--居中;-1--左对齐;1--右对齐</param>
/// <param name="verticalMode">竖直对齐方式:0--居中;-1--上对齐;1--下对齐</param>
/// <returns></returns>
public ObjectId insertText(string textstr,Point3d position,string styleName,double rotation,int horizontalMode,int verticalMode)
{
ObjectId textId;
Database db=Application.DocumentManager.MdiActiveDocument.Database;
DBTransMan tm=db.TransactionManager;
using(Transaction trans=tm.StartTransaction())
{
BlockTable bt=(BlockTable)trans.GetObject(db.BlockTableId,OpenMode.ForRead,false);
BlockTableRecord btr=(BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite,false);
DBText text=new DBText();
text.TextString=textstr;
text.AlignmentPoint=position;
text.Position=position;
text.TextStyle=TextStyleId(styleName);
text.Rotation=rotation;
switch(horizontalMode)
{
case 0:
text.HorizontalMode=TextHorizontalMode.TextCenter;
break;
case -1:
text.HorizontalMode=TextHorizontalMode.TextLeft;
break;
default:
text.HorizontalMode=TextHorizontalMode.TextRight;
break;
}
switch(verticalMode)
{
case 0:
text.VerticalMode=TextVerticalMode.TextVerticalMid;
break;
case -1:
text.VerticalMode=TextVerticalMode.TextTop;
break;
default:
text.VerticalMode=TextVerticalMode.TextBottom;
break;
}
textId=btr.AppendEntity(text);
trans.AddNewlyCreatedDBObject(text,true);
trans.Commit();
trans.Dispose();
}
return textId;
} |
|