参照官方提供的HorizontalAlignmentCreator例子尝试去构建一个Alignment,代码如下:
public
static
void
CreateAlignmentFromPoints(List<EXPoint3d> m_points)
{
string
m_featureDef =
""
;
m_featureName =
List<LinearElement> lines =
new
List<LinearElement>();
if
(m_points.Count < 2)
return
}
//adjusts x and y values
double
UorPerMas = 1;
DPoint3d startPoint =
DPoint3d(m_points[0].X, m_points[0].Y, m_points[0].Z);
startPoint.X *= UorPerMas;
startPoint.Y *= UorPerMas;
startPoint.Z *= UorPerMas;
for
(
int
i = 1; i < m_points.Count; i++)
DPoint3d endPoint =
DPoint3d(m_points[i].X, m_points[i].Y, m_points[i].Z);
endPoint.X *= UorPerMas;
endPoint.Y *= UorPerMas;
endPoint.Z *= UorPerMas;
//creates a line between each consectutive pair of points
Line line = Line.Create1(startPoint, endPoint);
lines.Add(line);
startPoint = endPoint;
LinearComplex complexAlign = LinearComplex.Create1(lines.ToArray(),
false
,
, 0.001);
ConsensusConnectionEdit con = ConsensusConnectionEdit.GetActive();
con.StartTransientMode();
Alignment al = con.GetActiveGeometricModel().CreateAlignmentByLinearElement(complexAlign,
true
);
con.PersistTransients();
//sets feature definition and feature name
(m_featureName !=
null
&& m_featureName !=
.Empty && m_featureDef !=
&& m_featureDef !=
.Empty)
al.SetFeatureDefinition(m_featureDef, m_featureName);
else
(m_featureDef !=
al.SetFeatureDefinition(m_featureDef);
在调试的时候,在运行CreateAlignmentByLinearElement时ORD崩溃了:
看了下exception.log日志,也没发现什么问题:
日志里面的CREATEMODELTEST TESTALIGNMENTFUNCTIONS就是调用构建Alignment函数的命令。
我所使用的ORDChina版本如下图
我看您Alignment都是点和点之间直接连接的,这种情况下不需要使用LinearComplex对象,而应该选用LineString对象一次创建出来即可。LinearComplex用于直线段和弧段或B样条曲线段混合的情况下。
不行,付老师,按照您说的我改成了使用linestring创建alignment,但是在创建的时候ORD还是崩溃了
有可能是你的SDK跟主程序不配套,因为目前ORD SDK编辑部分重构了。
另外,建议不要用空文件跑你的代码,如果是空文件跑你的代码,那么geometricModel是空的,目前需要保证当前模型里面存在ORD对象,所以首先需要手动在界面上创建alignment或者其他ORD对象后,再跑你的代码,这块是一个Bug我们目前已经抓紧时间修复了。
Answer Verified By: fanghua wei
好的,非常感谢张总的解答。通过参考您的说明,我已经能创建出Alignment了。