基础回顾
https://blog.csdn.net/liqian_ken/article/details/143867404
https://blog.csdn.net/liqian_ken/article/details/114851319
效果图
代码示例
- 在前文基础上,增加一个工具方法:
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
涉及了扫掠方向、圆心、半径的设置。
- 调用:
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");
}