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

Revit二次开发 钢筋生成API(一)

1、自由钢筋生成API

  创建不受约束的自由形式钢筋。以后不能将约束添加到此钢筋。

public static Rebar CreateFreeForm(Document doc,RebarBarType barType,Element host,IList<CurveLoop> curves,out RebarFreeFormValidationResult error
)

通过此方法,可以创建一个或者多个钢筋,钢筋创建完成后,无法修改钢筋的约束,意思如下图,钢筋的约束定义将无法修改

image

以上钢筋创建的案例代码如下:

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;namespace RebarExample.Cmds
{[Transaction(TransactionMode.Manual)][Regeneration(RegenerationOption.Manual)]public class CreateFreeForm2 : IExternalCommand{public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements){try{Document doc = commandData.Application.ActiveUIDocument.Document;if (doc == null)return Result.Failed;//查找到钢筋类型FilteredElementCollector fec = new FilteredElementCollector(doc).OfClass(typeof(RebarBarType));if (fec.GetElementCount() <= 0)return Result.Failed;RebarBarType barType = fec.FirstElement() as RebarBarType;//启动事务using (Transaction tran = new Transaction(doc, "CreateFreeForm2")){Element host = null;Selection sel = commandData.Application.ActiveUIDocument.Selection;try{//选择主体对象Reference hostRef = sel.PickObject(ObjectType.Element, "Select Host");host = doc.GetElement(hostRef.ElementId);if (host == null)return Result.Failed;}catch (Exception e){message = e.Message;return Result.Failed;}tran.Start();this.CreateFreeForm(doc, barType, host);tran.Commit();}return Result.Succeeded;}catch (Exception ex){message = ex.Message;return Result.Failed;}}/// <summary>/// 创建钢筋/// </summary>/// <param name="doc"></param>/// <param name="barType"></param>/// <param name="host"></param>private void CreateFreeForm(Document doc, RebarBarType barType, Element host){IList<CurveLoop> curves = new List<CurveLoop>();if (host is Wall wall){//创建钢筋var wline = (wall.Location as LocationCurve).Curve;if (wline != null){for (var i = 0; i < 5; i++){CurveLoop p = new CurveLoop();var start = wline.GetEndPoint(0);var end= wline.GetEndPoint(1);p.Append(Line.CreateBound(new XYZ(start.X,start.Y,start.Z+i*0.1),new XYZ(end.X,end.Y,end.Z+i*0.1)));curves.Add(p);}}}RebarFreeFormValidationResult error;Rebar rebar = Rebar.CreateFreeForm(doc, barType, host, curves, out error);}}
}

 

http://www.wxhsa.cn/company.asp?id=6652

相关文章:

  • 方法
  • 详细介绍:PHP基础-语法初步(第七天)
  • 如何通过Python SDK 删除 Collection
  • maven项目连接DM数据库和基本sql使用
  • 【中国计算机学会CCF主办】第六届人工智能、大数据与算法国际学术会议(CAIBDA 2026)
  • 图片 - voasem
  • 面试时让你设计一个“朋友圈点赞”功能测试,如何回答才出彩?
  • 企训宝教育培训微信小程序系统
  • Inventor Professional 2026.1.1 产品设计与工程制图
  • 叮当计步微信小程序系统
  • fetch-event-source踩坑sse(getReader)后续 IOS全量返回问题
  • P12508 「ROI 2025 Day2」程序员的日常
  • 手机上有哪些比较好用的待办事项提醒工具 - 指南
  • Redis源码学习 -- 数据类型编码 -- List - -蓝蜗牛
  • 乌班图无法登录桌面,只能终端登录用户。且有网拉不了包(DNS问题)
  • 事半功倍是蠢蛋53 tornado接口报错
  • 完整教程:云手机的技术架构可分为哪些
  • AI提示词遇见精密算法:TimeGuessr如何用数学魔法打造文化游戏新体验
  • Arkime:大规模开源网络分析与数据包捕获系统
  • kylin SP2安装mysql 8.0.41
  • SAP采购订单数据获取
  • get和post如何理解
  • me and my girlfriend WP复盘
  • 顺序表
  • 能源管理的数字神经:MyEMS如何重塑能效认知
  • 开源・数据・能效:MyEMS 如何成为能源管理革新的核心引擎
  • mysql回表,为什么你的查询总是慢半拍?
  • HMCL 3.6.17 Minecraft我的世界启动器
  • 用自带的Nginx为gitlab做白名单
  • XHR/Fetch请求介绍与安全测试