通过编程的方式根据一组封闭的线绘制相同形状的箍筋
来源:互联网 发布:普联软件怎么样 编辑:程序博客网 时间:2024/04/28 08:11
很多的时候我们希望给Revit的构件配筋, 通过编程的方式可以将你用手工绘制的模型线转化成箍筋。非常方便直观。
我们调用Rebar.CreateFromCurves() 函数来创建箍筋。
函数定义如下:
public static Rebar CreateFromCurves(
Document doc,
RebarStyle style,
RebarBarType barType,
RebarHookType startHook,
RebarHookType endHook,
Element host,
XYZ norm,
IList<Curve> curves,
RebarHookOrientation startHookOrient,
RebarHookOrientation endHookOrient,
bool useExistingShapeIfPossible,
bool createNewShape
)
创建箍筋需要注意的几个输入参数的理解:
第二个参数(RebarStyle style,)是 选择钢筋类型, 对于箍筋需要设置为: RebarStyle.StirupTie. 如果对于直线钢筋或纵筋设置为RebarStyle.Standard
第七个参数(XYZ norm) 是箍筋坐在平面的法向量方向。
请看下面的代码。
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)] public class Command1 : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { RebarBarType barType = null; RebarHookType hookType = null; Document doc = commandData.Application.ActiveUIDocument.Document; Transaction transaction = new Transaction(doc, "CreateRebar Tool"); try { transaction.Start(); IList<Curve> curves1 = new List<Curve>(); ElementSet eleset = commandData.Application.ActiveUIDocument.Selection.Elements; //需要确保这些选择的线是首尾相连的。 foreach (Element e in eleset) { if (e is ModelLine) { Line l = (e as ModelLine).GeometryCurve as Line; Line line = doc.Application.Create.NewLineBound(l.get_EndPoint(0), l.get_EndPoint(1)); curves1.Add(line); } } foreach (RebarBarType bt in doc.RebarBarTypes) { barType = bt; break; } foreach (RebarHookType ht in doc.RebarHookTypes) { hookType = ht; } { Reference hasPickOne = commandData.Application.ActiveUIDocument.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element); FamilyInstance hostFi = doc.get_Element(hasPickOne.ElementId) as FamilyInstance; Rebar rebar = CreateRebar1(commandData.Application.ActiveUIDocument, curves1, hostFi, barType, hookType); } } catch (Exception ex) { message += ex.Message; return Autodesk.Revit.UI.Result.Failed ; } finally { transaction.Commit(); } return Result.Succeeded ; } Rebar CreateRebar1( Autodesk.Revit.UI.UIDocument uidoc, IList<Curve> curves, FamilyInstance column, RebarBarType barType, RebarHookType hookType) { LocationPoint location = column.Location as LocationPoint; XYZ origin = location.Point; Rebar rebar = Rebar.CreateFromCurves(uidoc.Document, Autodesk.Revit.DB.Structure.RebarStyle.StirrupTie, barType, hookType, hookType, column, new XYZ(0,0,1), curves, RebarHookOrientation.Left, RebarHookOrientation.Left, true, true); return rebar; } }
转载请复制以下信息:
原文链接: http://blog.csdn.net/joexiongjin/article/details/8950238
作者: 叶雄进 , Autodesk ADN
- 通过编程的方式根据一组封闭的线绘制相同形状的箍筋
- 通过绘制上下文的方式绘制图片圆角
- 一个绘制眉毛形状的函数
- 一个绘制眉毛形状的函数
- 一个绘制眉毛形状的函数
- VC窗口形状的绘制---SetWindowRgn
- CSS绘制常见形状的图形
- 成员名称不能与它们的封闭类型相同
- 通过MD5加密的方式判断图片是否相同
- flex 绘制多边形/flex封闭图形的意义
- Spring Batch_使用多线程运行一组相同任务的JOB
- 递归输出一组元素的排列组合方式
- 很巧妙的一组动画实现方式
- 【Unity】模仿GUILayout.SelectionGird绘制一组互斥的按钮
- opencv绘制基本形状的二值图像
- photoshop给绘制的形状使用渐变工具
- 美轮美奂-随机绘制不同形状、色彩、大小、位置的图形
- OpenCV_Draw the Shape Descriptor(绘制图像的形状描述符)
- Android本地语音识别引擎PocketSphinx-语言建模
- iOS SDK:预览和打开文档
- ADT升级后Could not find class 'org.ksoap2.serialization.SoapObject'
- strdup
- Linux 多线程编程( POSIX )( 一 ) ----> 代码区
- 通过编程的方式根据一组封闭的线绘制相同形状的箍筋
- Spring.NET企业架构实践之 NHibernate + Spring.NET + WCF + Windows服务 + Silverlight 中小企业应用架构完整Demo
- sigprocmask()函数解释
- iOS 6 SDK: 在应用内展示App Store
- unspecified-bool-type
- 让Service在手机休眠后仍然运行
- Linux 多线程编程( POSIX )( 二 )----->pthread_attr_t 线程属性
- python----easy_install 安装和使用
- 对synchronized(this)的一些理解