RevitNet 调用 Revit API 中射线法求模型同一个构件出现两个不同值的问题记录
射线法求交是很多三维模型求碰撞和测量间距最常用的节点,但是再使用射线法将target设置为element的时候会发现会出现两个相同的值。下面用楼板距离,下图中会出现两个不同的值,在我修改板厚之后发现正好是板厚的距离,可以猜测射线法会对两个face进行判定相交,但是与我们需要的每个element输出一个值不符,这里需要重新做一次判定或者直接取最小值获得净高。 123456789101112131415161718var intersector = new ReferenceIntersector(classFilter, FindReferenceTarget.Element, modelView); intersector.FindReferencesInRevitLinks = true; var result = intersector.Find(origin, -XYZ.BasisZ); foreach (var context in result) ...
Revit API Ray Method Returns Two Values for Same Element Analysis
Ray intersection is one of the most commonly used nodes for collision calculation and distance measurement in many 3D models. However, when using the ray method and setting target to element, you will find that two identical values appear.Using floor distance as an example, two different values appear in the figure below. After I modified the slab thickness, I found that it was exactly the distance of the slab thickness. It can be guessed that the ray method determines intersection for both f...
Error Getting Grid Reference in Revit API
After Revit 2018, the method for obtaining Grid Reference has been modified. You need to use the following code to retrieve it: 12345foreach (Grid grid in grids) { var reference = new Reference(grid); gridReferences.Append(reference); } Previously, you needed to get the Grid’s Curve.Reference to create dimensions: 1gridReferences.Append(grid.Curve.Reference); The change should be made to obtain Grid References more safely and convenie...
Revit二次开发 Grid无法获取reference的报错
在Revit2018以后,修改了Grid的Reference获取办法,需要使用下面的代码进行获取 12345foreach (Grid grid in grids) { var reference = new Reference(grid); gridReferences.Append(reference); } 而在之前是需要获取Grid的Curve.Reference才能进行标注创建 1gridReferences.Append(grid.Curve.Reference); 改动应该是为了更加安全便捷的获取Grid的Refence而做出的修改。关于这个事情的官方回答详情可以看下面这篇文章Invalid Number of References
Breaking an Arc into Multiple Segments
The company plugin’s beam-to-slab function has been updated. The designer requested a feature to split arc beams and align them to the top of the slab. This article only discusses splitting arc beams; ellipses will be updated later. First, let’s look at the arc creation APIThe API provides three methods:The first one is specifying the start point and end point, and finally selecting a point on the arc.The second one is specifying the plane, radius, start angle, and end angle.The third one is...
Arc 打断拆分成多个线段
公司插件的梁齐斜板功能更新,设计师提出需求可以拆分弧梁,并能对齐到板顶。 本文只讨论拆分弧梁,椭圆再后续更新。 首先看以下弧形的创建apiAPI中提供了三种方法第一种时指定起点与终点,最后选择顶点形成的弧形第二种是指定面,半径,起点角度与终点角度第三种则是弧形中心点,半径,起点角度,终点角度,x向量,y向量 拆分弧形,意思就是如果遇到板边界需要拆分,需要将此弧形按照板边界划分成两个弧形,第一种办法肯定无法实现,后两种的化就需要了解什么是起点角度与终点角度,并如何计算 下面是我的理解,后面彻底完成后再继续补充,可能有些混乱,怕后面忘记(所有的弧形是逆时针旋转) 弧形内部有三个参数(xDir,yDir,normal),这三个参数代表横向向量,纵向向量,和法向量 下面是两个相反的值比较,可以发现法向量在俩面决定了整个弧形方向,此处可以使用右手法则理解 也就是说,此处如果按照常规布置,我们可以求startangle和endangle,公式如下所示: 12var dir0 = (arc.GetEndPoint(0) - arc.Center).Normalize(); ...
Revit二次开发 PromptForFamilyInstancePlacement 方法报错的解决办法
参照 这里是一些使用钩子进行取消的方案,但是在我的函数中运行失败,在这里记录一下后续在研究失败原因 Revit二次开发知识分享(十二)给Revit发送Esc按键如何在Revit中监听键盘事件 查阅SDK的内容,但是也是运行失败,放在这里看看后续有没有启发 123456789101112131415161718192021 // Use custom Revit drag and drop behavior LoadedFamilyDropHandler myhanlder = new LoadedFamilyDropHandler(); UIApplication.DoDragDrop(selectedItem.Tag, myhanlder);/// <summary> /// Custom handler for placement of loaded family types /// </summary> public class LoadedFamilyDrop...
Resolving PromptForFamilyInstancePlacement Error in Revit API
Reference Here are some solutions using hooks to cancel, but they failed in my function. Record here for researching failure reasons later. Revit secondary development knowledge sharing (12) Sending Esc key to RevitHow to listen to keyboard events in Revit Consulted SDK content, but also failed to run. Put it here to see if there is any inspiration later. 123456789101112131415161718192021 // Use custom Revit drag and drop behavior LoadedFamilyDropHandler myhanlder = new ...
Creating Parts in Revit Secondary Development
Some projects need to use parts to divide floor tiles, like this:Using parts can basically calculate quantities and set data such as paving joints, so below is a method to create parts. 12345678910111213PartUtils.CreateParts(doc,new List<ElementId>(){detailFloor.Id}); doc.Regenerate(); var elementIds = PartUtils.GetAssociatedParts(doc, detailFloor.Id, true, true); var maker = PartUtils.Divi...
Revit 二次开发 创建零件
有的项目需要使用零件进行地砖的划分,比如这样:使用零件可以很好的统计数量,设置铺设缝等数据,所以下面提供一个可以创建零件的方法 12345678910111213PartUtils.CreateParts(doc,new List<ElementId>(){detailFloor.Id}); doc.Regenerate(); var elementIds = PartUtils.GetAssociatedParts(doc, detailFloor.Id, true, true); var maker = PartUtils.DivideParts(doc, elementIds, new List<ElementId>() { }, curves, ske.Id); ...
Managing Multiple WPF Commands via Dictionary
Developing a family library plugin involves many interactive commands and requires many bindings. Using MVVM to directly bind Commands makes the entire ViewModel too messy. Here, an ICommandManage interface is created to manage Commands. The ValueConvert interface in WPF is used to convert the passed string into an ICommand command. C# 12345678910111213141516171819202122232425public interface ICommandManager { void RegisterCommand(string name, ICommand? command); void Un...
WPF 通过一个dictionary管理多个Command注册
需要开发一个族库插件,中间交互的命令很多,需要很多绑定,使用MVVM 直接绑定Command觉得整个ViewModel会过于杂乱,这里通过创建一个ICommandManage的接口管理Command。通过WPF中ValueConvert接口将传入字符串转换成ICommand命令。 c# 12345678910111213141516171819202122232425public interface ICommandManager { void RegisterCommand(string name, ICommand? command); void UnRegisterCommand(string name); ICommand GetCommand(string name); }public class CommandManager:ICommandManager { private readonly Dictionary<string, ICommand?> ...
Modifying Filled Region Line Styles in Revit API
I made a plugin to automatically calculate the clear height, which requires marking the height with annotation blocks, but boundary lines appeared when it came out, as shown below. Defining width through filledregionType’s lineweight failed, and setting through LineStyleId also failed because directly obtaining LineStyle style only gets lines in Manage -> Line Styles, not the category we need.Here we need to collect GraphStyle to find the invisible line Id and assign it directly. In the e...
Revit 二次开发修改填充区域线样式
做了一个自动测算净高的插件,需要通过注释块标记高度,但是出来的时候会有边界线,如下图,通过filledregionType的lineweight定义宽度失败,通过LineStyleId进行设置,但是直接获取LineStyle样式只会获取管理->线样式里面的线,没有我们需要的<不可见线>这个分类。此处需要收集以下GraphStyle找到不可见线Id直接赋值即可,实例中我将绿色的部分进行边界取消 123456789var filter = new FilteredElementCollector(doc); var dates = filter.OfClass(typeof(GraphicsStyle)).ToElements(); var line = dates.Where(x => x.Name.Contains("线")).ToList(); var fake = line.FirstOrDefault(x => x.Name.Contains("不...
UE5 Configure VR Project Environment
The whole step borrowed article https://blog.csdn.net/weixin_44350205/article/details/119233809 But still reported error. I organize and record my own steps ConfigurationCan check ue official configuration requirements for different versions https://docs.unrealengine.com/5.0/zh-CN/android-development-requirements-for-unreal-engine/ Configure EnvironmentMy java environment is 12.0.2 satisfying requirements, because installed before so no need to reinstall here. If need to configure can fo...
UE5配置VR项目环境
整个步骤借鉴的文章 https://blog.csdn.net/weixin_44350205/article/details/119233809 但是还是依旧报错,我把我自己的步骤整理记录一下 配置可以查看ue官方对于不同版本的配置要求 https://docs.unrealengine.com/5.0/zh-CN/android-development-requirements-for-unreal-engine/ 配置环境我的java环境是12.0.2满足要求,因为是之前安装好的所以此处不需要重新安装,如果需要配置的可以按照网上环境配置2.1 配置android studio下载ide主要是为了使用ide生成项目,sutdio的下载地址: https://developer.android.google.cn/studio 2.2 下载好studio后我们需要配置sdk 这个位置主要是为了后期可以调用ue5自己的配置脚本 在ue5中配置android sdk的信息此处参照第一个链接或是官方链接进行配置 https://docs.unrealengine...
Revit 二次开发 创建紧凑型pushbutton
为了好理解叫做紧凑型Button起始应该是栈式Button,关键词StackedItems,效果如下图 https://knowledge.autodesk.com/support/revit/learn-explore/caas/CloudHelp/cloudhelp/2014/ENU/Revit/files/GUID-1547E521-59BD-4819-A989-F5A238B9F2B3-htm.html 上面的引用连接中,介绍了每个按钮的使用,并且配备有详细的代码,可以参照上面的博客进行查询练习。 因为需要到这个命令的应该是有足够数量的开发人员,所以直接上代码需要的添加即可 注意事项: 图标像素为 16*16 命名不宜过长,否则不显示,建议补充在tooltip中 12345arPanel.AddSeparator(); arPanel.AddStackedItems(createParkingData,createParkingCodeData,createMonitorChange); arPanel.AddSe...
Creating Stacked PushButtons in Revit API
To make it easier to understand, it is called Compact Button, but it should actually be called Stacked Button. The keyword is StackedItems. The effect is shown below: https://knowledge.autodesk.com/support/revit/learn-explore/caas/CloudHelp/cloudhelp/2014/ENU/Revit/files/GUID-1547E521-59BD-4819-A989-F5A238B9F2B3-htm.html The reference link above introduces the usage of each button and provides detailed code, which can be referred to for query practice. Because those who need this command sh...
Revit二次开发使用MaterialDesignThemes.Wpf
在开发Revit插件的时候很多会使用WPF创建窗口,我这里引用了MaterialDesignThemes这个组件,在这个文章里面记录一下相应的步骤和问题 使用安装 直接从nuget中搜索MaterialDesignThemes安装 添加reosurces 123456789101112<Window.Resources> <ResourceDictionary> <viewmodel:ObjectConvert x:Key="ObjectConverter" ></viewmodel:ObjectConvert> <ResourceDictionary.MergedDictionaries> <materialDesign:BundledTheme BaseTheme="Light" PrimaryColor=&...
Using MaterialDesignThemes.Wpf in Revit Secondary Development
Often when developing Revit plugins, WPF is used to create windows. Here I referenced the MaterialDesignThemes component, and I will record the corresponding steps and issues in this article. UsageInstallation Search for MaterialDesignThemes directly from nuget and install it. Add resources 123456789101112<Window.Resources> <ResourceDictionary> <viewmodel:ObjectConvert x:Key="ObjectConverter" ></viewmodel:ObjectConvert> <Resou...











