如何绘一个文字自动剧中的标注 ?
C#开发|黄洪辉|2018-06-11 11:38
-
回答:
主要用到函数说明:
_DMxDrawX::DrawDimRotated
绘制一个线型标注。详细说明如下:
参数 说明 DOUBLE dExtLine1PointX
输入第一条界线的起始点X值
DOUBLE dExtLine1PointY
输入第一条界线的起始点Y值
DOUBLE dExtLine2PointX
输入第二条界线的起始点X值
DOUBLE dExtLine2PointY
输入第二条界线的起始点Y值
DOUBLE dDimLineLocationX
输入标注线自身上的点X值
DOUBLE dDimLineLocationY
输入标注线自身上的点Y值
DOUBLE dRotationAngle
输入标注的旋转角
实现代码说明:
MxDrawDatabase MxDrawDatabase1 = (MxDrawDatabase)axMxDrawX1.GetDatabase(); MxDrawDatabase1.LinetypeScale = 15; MxDrawDimStyleTableRecord curDimRecord = MxDrawDatabase1.GetDimStyleTable().GetAt(MxDrawDatabase1.CurrentlyDimstyleName, false); MxDrawTextStyleTableRecord curTextRecord = MxDrawDatabase1.GetTextStyleTable().GetAt(MxDrawDatabase1.CurrentlyTextStyle, false); curDimRecord.SetDimVarDouble(40, 1000);//设置缩放比例Dimscale curDimRecord.SetDimVarInt(271, 0);//设置两位小数DimDle curDimRecord.SetDimVarInt(173, 1); //设置需要显示符号 curDimRecord.SetDimVarInt(289, 3); curDimRecord.SetDimVarInt(174, 1); curDimRecord.SetDimVarString(342, "_ARCHTICK"); //设置建筑标记 curTextRecord.bigFontFileName = "gbcbig.shx"; curTextRecord.fileName = "tssdeng.shx"; curTextRecord.Name = "默认样式"; Int64 dimID = axMxDrawX1.DrawDimRotated(100, 100, 100, 200, 200, 150, 0); MxDrawDimension Dim = (MxDrawDimension)axMxDrawX1.ObjectIdToObject(dimID); Dim.DimensionText = "100"; Dim.SetDimVarInt(173, 1); //设置需要显示符号 Dim.SetDimVarInt(289, 0); Dim.SetDimVarInt(174, 1); Dim.SetDimVarString(342, "_ARCHTICK"); //设置建筑标记 MxDrawPoint textPos = new MxDrawPoint(); textPos.x = 200; textPos.y = 150; Dim.TextPosition = textPos; Dim.UsingDefaultTextPosition = false; Dim.RecomputeDimBlock(true); axMxDrawX1.UpdateDisplay(); axMxDrawX1.ZoomAll();