当前位置: 首页 > news >正文

【Xbim+C#】创建拉伸的墙

基础

基础回顾

效果图

在这里插入图片描述

简单的工具类

using System.Collections.Generic;
using System.Linq;
using Xbim.Common.Step21;
using Xbim.Ifc;
using Xbim.Ifc4.GeometricConstraintResource;
using Xbim.Ifc4.GeometricModelResource;
using Xbim.Ifc4.GeometryResource;
using Xbim.Ifc4.Interfaces;
using Xbim.Ifc4.Kernel;
using Xbim.Ifc4.MeasureResource;
using Xbim.Ifc4.PresentationAppearanceResource;
using Xbim.Ifc4.ProductExtension;
using Xbim.Ifc4.ProfileResource;
using Xbim.Ifc4.RepresentationResource;
using Xbim.Ifc4.SharedBldgElements;namespace TestXbim
{public class IfcUtil{public static IfcStore MakeIfcStore(){return IfcStore.Create(IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel);}public static IfcProject CreateProject(IfcStore model){return model.Instances.New<IfcProject>(p =>{p.UnitsInContext = model.Instances.New<IfcUnitAssignment>(a =>a.SetOrChangeSiUnit(IfcUnitEnum.LENGTHUNIT, IfcSIUnitName.METRE, IfcSIPrefix.MILLI));});}public static IfcSite CreateSite(IfcStore model){return model.Instances.New<IfcSite>();}public static IfcBuilding CreateBuilding(IfcStore model){return  model.Instances.New<IfcBuilding>();  }public static IfcWall CreateWall(IfcStore model){return model.Instances.New<IfcWall>();  }       public static IfcProductDefinitionShape CreateExtrudedShape(IfcStore model, List<double[]> points, double depth, double elevation){//基于点坐标序列,创建折线IfcPolyline polyline = model.Instances.New<IfcPolyline>(L =>{foreach (var point in points){IfcCartesianPoint p = model.Instances.New<IfcCartesianPoint>(cp => cp.SetXY(point[0], point[1]));L.Points.Add(p);}});//基于折线创建切面var profileDef = model.Instances.New<IfcArbitraryClosedProfileDef>(p =>{p.ProfileType = IfcProfileTypeEnum.AREA;p.OuterCurve = polyline;});//基于切面创建拉伸体var solid = model.Instances.New<IfcExtrudedAreaSolid>(s =>{s.Position = model.Instances.New<IfcAxis2Placement3D>(p =>p.Location = model.Instances.New<IfcCartesianPoint>(c => c.SetXYZ(0, 0, elevation)));s.Depth = depth;s.ExtrudedDirection = model.Instances.New<IfcDirection>(d => d.SetXYZ(0, 0, 1));s.SweptArea = profileDef;});//基于拉伸体,创建形状var rep = model.Instances.New<IfcShapeRepresentation>(r =>{r.Items.Add(solid);});//基于形状,创建产品形状var shape = model.Instances.New<IfcProductDefinitionShape>(s => s.Representations.Add(rep));return shape;}        }
}

示例代码

public void TestMethod1()
{var pts = new List<double[]>(){new double[]{0,0},new double[]{0,1000},new double[]{2000,1000},new double[]{2000,0},};var pts2 = new List<double[]>(){new double[]{0,1500},new double[]{0,2500},new double[]{1000,2500},new double[]{1000,1500},};var model = IfcUtil.MakeIfcStore();using (var tran = model.BeginTransaction()){var color = new double[] { 0.5, 0, 0, 2 };var wallShape = IfcUtil.CreateExtrudedShape(model, pts, 500, 0);var wall = IfcUtil.CreateWall(model);wall.Representation = wallShape;var wallShape2 = IfcUtil.CreateExtrudedShape(model, pts2, 500, 0);var wall2 = IfcUtil.CreateWall(model);wall2.Representation = wallShape2;var building = IfcUtil.CreateBuilding(model);building.AddElement(wall);building.AddElement(wall2);var site = IfcUtil.CreateSite(model);site.AddBuilding(building);var project = IfcUtil.CreateProject(model);project.AddSite(site);tran.Commit();}model.SaveAs("./wall.ifc");
}
http://www.lryc.cn/news/489188.html

相关文章:

  • 【阅读记录-章节3】Build a Large Language Model (From Scratch)
  • three.js 对 模型使用 视频进行贴图修改材质
  • MySQL - 数据库基础 | 数据库操作 | 表操作
  • maven父子项目
  • NLP论文速读(多伦多大学)|利用人类偏好校准来调整机器翻译的元指标
  • MyBatis——#{} 和 ${} 的区别和动态 SQL
  • 解决sql字符串
  • 深度解析:Android APP集成与拉起微信小程序开发全攻略
  • Leetcode 被围绕的区域
  • ssm框架-spring-spring声明式事务
  • React第五节 组件三大属性之 props 用法详解
  • 测评部署和管理 WordPress 最方便的面板
  • 【系统分析师】-2024年11月论文-论DevOps开发
  • 算法【子数组最大累加和问题与扩展】
  • 小程序23-页面的跳转:navigation 组件详解
  • AI社媒引流工具:解锁智能化营销的新未来
  • 【Node.js】全面解析 Node.js 安全最佳实践:保护您的应用
  • Docker 用法详解
  • Python小游戏28——水果忍者
  • Kafka Offset 自动提交和手动提交 - 漏消费与重复消费
  • Vue3父组件和子组件
  • Linux 定时任务全解析
  • XLNet——打破 BERT 局限的预训练语言模型
  • 开源代码统计工具cloc的简单使用
  • 如何创建一个项目用于研究element-plus的原理
  • 单片机进阶硬件部分_day2_项目实践
  • labview关于文件路径的问题
  • 72项!湖北省2024年度第二批省级科技计划项目拟立项项目公示!
  • 神经网络问题之:梯度不稳定
  • ORACLE删不掉job,如何解决。