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

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

2、自由钢筋生成API

创建一条无约束的自由形状钢筋。之后无法对该钢筋添加约束。

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

这个合自由钢筋生成API(一)本质上没有区别,唯一的区别就是参数

IList<CurveLoop> curves 和IList<IList<Curve>> curves的不同。

这个就要看CurveLoop和IList<Curve>的区别。

  • CurveLoop:曲线循环的集合,通常用于定义建筑模型的几何边界或路径,默认会把首位相连
  • IList<Curve>:可以定义一个有多个线段组成的整线,比较适合各种形状的钢筋。

此函数的案例如下:

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 CreateFreeForm3 : 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<IList<Curve>> curves = new List<IList<Curve>>();if (host is Wall wall){//创建钢筋var wline = (wall.Location as LocationCurve).Curve;if (wline != null){for (var i = 0; i < 5; i++){List<Curve> ps = new List<Curve>();var start = wline.GetEndPoint(0);var end = wline.GetEndPoint(1);var v1 = new XYZ(start.X+0.5, start.Y, start.Z + i * 0.1);var v2 = new XYZ(end.X-0.5, end.Y, end.Z + i * 0.1);Curve l1 = Line.CreateBound(v1, v2);var v3 = new XYZ(end.X-0.5, end.Y + 0.5, end.Z + i * 0.1);Curve l2 = Line.CreateBound(v2, v3);ps.Add(l1);ps.Add(l2);curves.Add(ps);}}}RebarFreeFormValidationResult error;Rebar rebar = Rebar.CreateFreeForm(doc, barType, host, curves, out error);}}
}


生成结果展示如下:

image

 

http://www.zskr.cn/news/6820.html

相关文章:

  • Uri uri = new Uri(Path); 这行代码的作用
  • new 和make 切片和map
  • Git 常用操作指南
  • 【光照】[自发光Emission]以UnityURP为例
  • mybatis-plus初体验,解决报错Invalid value type for attribute factoryBeanObjectType: java.lang.String
  • 04_UDP协议
  • 从0到1搭建数据分析自动化程序链,AI应用架构师的实战指南
  • IOS App技术支持网址(URL)
  • C++ 内存管理
  • The 2024 CCPC Online Contest 7/12 L/B/K/D/J/E/C
  • 在joule里面使用agent 功能
  • qoj10093 Jump the Frog
  • new 和make
  • 墨刀是否能替代Axure?从产品经理三大画图能力深度分析
  • 唯创知音AI语音交互芯片与模组介绍
  • 用 Go 重写 adbkit:原理、架构与搭建实践
  • C语言环境搭建之Linux子系统使用vscode连接子系统
  • Ubuntu filebrowser网盘工具安装
  • 微信社群机器人接口
  • Revit二次开发 钢筋生成API(一)
  • 如何通过Python SDK 删除 Collection
  • 图片大全 - voasem
  • 面试时让你设计一个“朋友圈点赞”功能测试,如何回答才出彩?
  • 乌班图无法登录桌面,只能终端登录用户。且有网拉不了包(DNS问题)
  • 完整教程:云手机的技术架构可分为哪些
  • AI提示词遇见精密算法:TimeGuessr如何用数学魔法打造文化游戏新体验
  • Arkime:大规模开源网络分析与数据包捕获系统
  • get和post如何理解
  • me and my girlfriend WP复盘
  • 顺序表