图纸自动生成工具
在目前的设计模式中,作为表达工程信息的载体,如何生成一系列符合标准的图纸是衡量价值的重要标准,同时,生成图纸的效率与准确性也体现了生产力与质量。对于一些较为标准的构件,我们可以根据其特点抽象出其构建规则,以适用于该大类的所有构件,使用二次开发的方式自动根据模型信息生成图纸,与传统的图纸绘制相比,从模型到图纸的过程使用编程的方式自动生成,从而大幅度的提高制图效率。
需求说明:
使用工具对生成的构件进行图纸的输出。
要求:
通过绘制确定构件的最终形态,并在生成的图纸上对构件执行二维标注。
分析:
该工具大致可分为两个阶段:绘制构件阶段与生成图纸阶段,前者需要使用交互式工具,绘制出用于出图的构件,后者会依次创建NamedBoundary,SavedView与DrawingModel,并将SavedView参考到模型中,最后执行图纸中构件的标注。
using Bentley.DgnPlatformNET;
return viewinfo;
}
private NamedBoundary CreateNamedBoundary(Element elem,string boundaryGroupName,string boundaryName)
{
NamedBoundaryGroup boundaryGroup = NamedBoundaryGroup.CreateNamedBoundaryGroup(Session.Instance.GetActiveDgnModel(), boundaryGroupName, "");//创建NamedBoundaryGroup
NamedBoundary boundary = new NamedBoundary();//声明NamedGroup
boundary.ModelRef = m_dgnModel;//设置NamedGroup参照模型
boundary.Name = boundaryName;//设置NamedGroup名称
boundary.DrawingScale = 1;//设置NamedGroup绘制比例
boundary.GraphicalElement = elem;//设置NamedGroup图像元素
boundary.Save();//保存NamedGroup设置
boundaryGroup.InsertBoundary(boundary);//在NamedBoundaryGroup中导入NamedGroup
boundaryGroup.WriteToFile();//将NamedBoundaryGroup信息写入
return boundary;//返回NamedBoundary
}
}
class CreateDimensionCallbacks : DimensionCreateData
{
private DimensionStyle m_dimStyle;
private DgnTextStyle m_textStyle;
private Symbology m_symbology;
private LevelId m_levelId;
private DirectionFormatter m_directionFormatter;
public CreateDimensionCallbacks(DimensionStyle dimStyle, DgnTextStyle textStyle, Symbology symb, LevelId levelId, DirectionFormatter formatter)
{
m_dimStyle = dimStyle;
m_textStyle = textStyle;
m_symbology = symb;
m_levelId = levelId;
m_directionFormatter = formatter;
}
public override DimensionStyle GetDimensionStyle()
{
return m_dimStyle;
}
public override DgnTextStyle GetTextStyle()
{
return m_textStyle;
}
public override Symbology GetSymbology()
{
return m_symbology;
}
public override LevelId GetLevelId()
{
return m_levelId;
}
public override int GetViewNumber()
{
return 0;
}
//此函数返回的旋转矩阵与GetViewRotation返回的旋转矩阵共同定义了尺寸标注元素的方向
public override DMatrix3d GetDimensionRotation()
{
return DMatrix3d.Identity;
}
public override DMatrix3d GetViewRotation()
{
return DMatrix3d.Identity;
}
//用于从数字方向值构造字符串。
public override DirectionFormatter GetDirectionFormatter()
{
return m_directionFormatter;
}
}
}