当前位置: 首页 > 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.zskr.cn/news/6726.html

相关文章:

  • 如何通过Python SDK 删除 Collection
  • 图片大全 - voasem
  • 面试时让你设计一个“朋友圈点赞”功能测试,如何回答才出彩?
  • 乌班图无法登录桌面,只能终端登录用户。且有网拉不了包(DNS问题)
  • 完整教程:云手机的技术架构可分为哪些
  • AI提示词遇见精密算法:TimeGuessr如何用数学魔法打造文化游戏新体验
  • Arkime:大规模开源网络分析与数据包捕获系统
  • get和post如何理解
  • me and my girlfriend WP复盘
  • 顺序表
  • 开源・数据・能效:MyEMS 如何成为能源管理革新的核心引擎
  • HMCL 3.6.17 Minecraft我的世界启动器
  • go 变量作用域
  • ​​电流互感器选型指南:以普科科技产品为例
  • 读书笔记:白话解读位图索引:什么时候该用,什么时候千万别用?
  • RepositoryItemGridLookUpEdit 使用 ok
  • 谈谈程序猿的职业方向
  • reLeetCode 热题 100-11 盛最多的谁 - MKT
  • C# Avalonia 15- Animation- XamlAnimation
  • 域名购买方案
  • Anby_の模板题集
  • AI 编程的“最后一公里”:当强大的代码生成遇上模糊的需求
  • 使用bash脚本检测网站SSL证书是否过期 - sherlock
  • Python 2025:低代码开发与自动化运维的新纪元 - 教程
  • 一句话让AI帮你搞营销?火山引擎Data Agent说:这事儿可以的~
  • 网络安全反模式:无效工作生成器的根源与解决方案
  • Excel处理控件Aspose.Cells教程:如何将Excel区域转换为Python列表
  • LOJ #3835. 「IOI2022」千岛 题解
  • Ubuntu取消vim自动对齐
  • 中文医学基准测试题库数据集:28万条标准化JSON格式医师考试题目与临床案例分析,覆盖28个医学专业领域,用于医学AI模型训练、临床决策支持系统开发、医学知识问答系统构建、医学教育辅助工具优化