如图的一个标记,如果表格内字过多时,我想让字换行,如何处理?
如果直接加换行符,里面的文本是不认识的。
试试下面的代码:
DgnFile dgnFile = Session.Instance.GetActiveDgnFile(); DgnModel dgnModel = Session.Instance.GetActiveDgnModel(); TextBlockProperties txtBlockProp = new TextBlockProperties(dgnModel); txtBlockProp.IsViewIndependent = false; ParagraphProperties paraProp = new ParagraphProperties(dgnModel); DgnTextStyle txtStyle = DgnTextStyle.GetSettings(dgnFile); RunProperties runProp = new RunProperties(txtStyle, dgnModel); TextBlock txtBlock = new TextBlock(txtBlockProp, paraProp, runProp, dgnModel); txtBlock.AppendText("This is a textBlock Element"); txtBlock.AppendLineBreak(); txtBlock.AppendText("This is a another line"); TextHandlerBase txtHandlerBase = TextHandlerBase.CreateElement(null, txtBlock); DTransform3d trans = DTransform3d.Identity; trans.Translation = new DVector3d(6 * UorPerMas, 2 * UorPerMas, 3 * UorPerMas); //UOR unit TransformInfo transInfo = new TransformInfo(trans); txtHandlerBase.ApplyTransform(transInfo); RgbColorDef rgbColorDef = dgnFile.GetColorMap().GetColor(5); int color = rgbColorDef.ToInt(); ElementPropertiesSetter elePropSet = new ElementPropertiesSetter(); elePropSet.SetColor(5); elePropSet.Apply(txtHandlerBase); txtHandlerBase.AddToModel();
TextElement是可以实现换行 但是我的这个是一个TagElement