6.3.6.3实例3:根据模板及点控制生成solid实体 using BCIMNETGS = Bentley.CIMNET.CIMGeometry.Solid; using BCIMNETT = Bentley.CIMNET.CIMTemplate; using BCIFLG = Bentley.CifNET.LinearGeometry; /*---------------------------------------------------------------------------------**//** *点控制的设置。 *PointControlpPath: 控制曲线, 生成实体过程中solid横断面对应点延该曲线变化 *modelRef: PointControlpPath所在的Dgnmodel +---------------+---------------+---------------+---------------+---------------+------*/ List<BCIMNETGS.PointControl> GetPointControls(CurveVector PointControlpPath, DgnModelRef modelRef) { List<BCIMNETGS.PointControl> pointControls = new List<BCIMNETGS.PointControl>(); string pointName = "P_0"; //对应参数化模板中需要点控制方法控制的点的名称 pointControls.Add(new BCIMNETGS.PointControl(pointName, BCIMNETGS.PointControlDirection.Both, PointControlpPath, modelRef)); return pointControls; } /*---------------------------------------------------------------------------------**//** *使用点控制生成solid实体。 *solidTemplate: 参数化模板 *planLinearElement: 实体生成路径的平曲线 *profileElement: 实体生成路径的纵曲线 *startLimitLine: 实体的起点限制曲线 *endLimitLine: 实体的终点限制曲线 +---------------+---------------+---------------+---------------+---------------+------*/ void Example_CreateSolidWithSolidTemplate(BCIMNETT.Template solidTemplate, BCIFLG.LinearElement planLinearElement, BCIFLG.ProfileElement profileElement, BCIFLG.LinearElement startLimitLine, BCIFLG.LinearElement endLimitLine, DgnModelRef modelRef) { // 构造 SolidCorridor, 可根据参数选择生成的实体横断面垂直于地面或垂直于路径。 BCIMNETGS.SolidCorridor corridor = new BCIMNETGS.SolidCorridor(planLinearElement, profileElement, BCIMNETGS.SectionVerticalRotation.Vertical); // 添加SolidCorridorInternal, 确定solid实体段的生成规则 corridor.AddSolidCorridorInterals("Segement_1", solidTemplate, parametricConstraints, modelRef, startLimitLine, endLimitLine, 0.0, 0.0); // 设置点控制 List<BCIMNETGS.PointControl> pointControls = GetPointControls(); if (pointControls != null) corridor.AddPointControls("Segement_1", pointControls); // 生成实体并获取结果 BCIMNETGS.ISolidCreator solidFromCorridor = new BCIMNETGS.ISolidCreator(corridor, modelRef); solidFromCorridor.CreateSolid(); List<SolidKernelEntity> solidBodies = new List<SolidKernelEntity>(); solidFromCorridor.GetSolidBodies(solidBodies); foreach (SolidKernelEntity solid in solidBodies) { if (solid != null) { Bentley.DgnPlatformNET.Elements.Element ehOut; Bentley.DgnPlatformNET.Convert1.BodyToElement(out ehOut, solid, null, modelRef); ehOut.AddToModel(); } } }