惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
博客园 - 叶小钗
Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
美团技术团队
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
Microsoft Security Blog
Microsoft Security Blog
H
Heimdal Security Blog
有赞技术团队
有赞技术团队
The Cloudflare Blog
S
Secure Thoughts
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
The Blog of Author Tim Ferriss
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
小众软件
小众软件
C
Cybersecurity and Infrastructure Security Agency CISA
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - Franky
T
Tenable Blog
The Last Watchdog
The Last Watchdog
腾讯CDC
量子位
Google DeepMind News
Google DeepMind News
Help Net Security
Help Net Security
雷峰网
雷峰网
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyberwarzone
Cyberwarzone
S
Securelist
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
I
InfoQ
Spread Privacy
Spread Privacy
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - Albert_MIN

在 ASP.NET Core MVC 中,接收数据的几种方式 Content-Type 对应不同的前端数据结构与构造方式 Revit二次开发 钢筋生成API(二) revit二次开发 钢筋布置方式 revit二次开发之 钢筋功能详细分析 revit 二次开发之收集器、过滤器和选择器 Revit Server的注意要配置说明 WCF文件配置服务 WCF服务的各种绑定 Revit二次开发之 对象的隐藏与显示 Revit二次开发之 GeometryObject分析 Revit二次开发之 Material 分析 Revit二次开发之 PolymeshTopology Revit 二次开发之 图纸的导出 Revit开发之 IExportContext接口详细 JavaScript 困惑之 ArrayBuffer JS 困惑之this的指向 Revit二次开发之 族的创建 Revit二次开发 钢筋生成 Revit二次开发之 尺寸标线(二) Revit二次开发之 尺寸标线
Revit二次开发 钢筋生成API(一)
Albert_MIN · 2025-09-17 · via 博客园 - Albert_MIN

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);
        }
    }
}