自学内容网 自学内容网

【Xbim+C#】创建圆盘扫掠IfcSweptDiskSolid

基础回顾

https://blog.csdn.net/liqian_ken/article/details/143867404
https://blog.csdn.net/liqian_ken/article/details/114851319

效果图

在这里插入图片描述

在这里插入图片描述

代码示例

  1. 前文基础上,增加一个工具方法:
public static IfcProductDefinitionShape CreateDiskSolidShape(IfcStore model)
{
    IfcSweptDiskSolid solid = model.Instances.New<IfcSweptDiskSolid>(so =>
    {
        // 为扫描模型创建扫描曲线
        so.Directrix = model.Instances.New<IfcTrimmedCurve>(c =>
        {
            c.SenseAgreement = false;
            c.MasterRepresentation = IfcTrimmingPreference.CARTESIAN;
            c.Trim1.Add(model.Instances.New<IfcCartesianPoint>(pt => pt.SetXYZ(0, 2000, 0)));
            c.Trim2.Add(model.Instances.New<IfcCartesianPoint>(pt => pt.SetXYZ(2000, 0, 0)));
            c.BasisCurve = model.Instances.New<IfcCircle>(x =>
            {
                x.Radius = 1000;
                x.Position = model.Instances.New<IfcAxis2Placement3D>(a =>
                {
                    a.Location = model.Instances.New<IfcCartesianPoint>(pt => pt.SetXYZ(0, 0, 0));
                });
            });
        });
        so.Radius = 100;
        so.InnerRadius = 100;

    });
    var rep = model.Instances.New<IfcShapeRepresentation>(r =>
    {
        r.Items.Add(solid);
    });
    return model.Instances.New<IfcProductDefinitionShape>(s => s.Representations.Add(rep));
}

关于IFC裁剪线IfcTrimmedCurve的参数理解可以参考:https://blog.csdn.net/liyazhen2011/article/details/82259083

涉及了扫掠方向、圆心、半径的设置。


  1. 调用:
public void TestMethod1()
{
    var model = IfcUtil.MakeIfcStore();
    using (var tran = model.BeginTransaction())
    {
        var shape = IfcUtil.CreateDiskSolidShape(model);
        var arch = IfcUtil.CreateFlowFitting(model);
        arch.Representation = shape;

        var building = IfcUtil.CreateBuilding(model);
        building.AddElement(arch);

        var site = IfcUtil.CreateSite(model);
        site.AddBuilding(building);

        var project = IfcUtil.CreateProject(model);
        project.AddSite(site);

        tran.Commit();
    }

    model.SaveAs("./B.ifc");
}

原文地址:https://blog.csdn.net/liqian_ken/article/details/143868478

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!