Revit-二开之东西南北立面FilledRegion的CurveLoop计算-(4)

东西南北FilledRegion的CurveLoop计算

上一篇以东立面视图为例创建FilledRegion,接下来我们将立面视图创建FilledRegion的CurveLoop汇总一下。
在这里插入图片描述
上图是对四个立面坐标系间的绘制方便我们计算FilledRegion的CurveLoop。

东立面CurveLoop计算

private CurveLoop GetEastCurveLoop(XYZ leftUpPoint, double width, double height)
{XYZ point1 = leftUpPoint;XYZ point2 = point1 + XYZ.BasisY * width;XYZ point3 = point2 + -XYZ.BasisZ * height;XYZ point4 = point1 + -XYZ.BasisZ * height;CurveLoop curveloop = new CurveLoop();Line line1 = Line.CreateBound(point1, point2);Line line2 = Line.CreateBound(point2, point3);Line line3 = Line.CreateBound(point3, point4);Line line4 = Line.CreateBound(point4, point1);curveloop.Append(line1);curveloop.Append(line2);curveloop.Append(line3);curveloop.Append(line4);return curveloop;
}

西立面CurveLoop计算

private CurveLoop GetWestCurveLoop(XYZ leftUpPoint, double width, double height)
{XYZ point1 = leftUpPoint;XYZ point2 = point1 - XYZ.BasisY * width;XYZ point3 = point2 - XYZ.BasisZ * height;XYZ point4 = point1 - XYZ.BasisZ * height;CurveLoop curveloop = new CurveLoop();Line line1 = Line.CreateBound(point1, point2);Line line2 = Line.CreateBound(point2, point3);Line line3 = Line.CreateBound(point3, point4);Line line4 = Line.CreateBound(point4, point1);curveloop.Append(line1);curveloop.Append(line2);curveloop.Append(line3);curveloop.Append(line4);return curveloop;
}

南立面CurveLoop计算

private CurveLoop GetSouthCurveLoop(XYZ leftUpPoint, double width, double height)
{XYZ point1 = leftUpPoint;XYZ point2 = point1 + XYZ.BasisX * width;XYZ point3 = point2 - XYZ.BasisZ * height;XYZ point4 = point1 - XYZ.BasisZ * height;CurveLoop curveloop = new CurveLoop();Line line1 = Line.CreateBound(point1, point2);Line line2 = Line.CreateBound(point2, point3);Line line3 = Line.CreateBound(point3, point4);Line line4 = Line.CreateBound(point4, point1);curveloop.Append(line1);curveloop.Append(line2);curveloop.Append(line3);curveloop.Append(line4);return curveloop;
}

北立面CurveLoop计算

private CurveLoop GetNorthCurveLoop(XYZ leftUpPoint, double width, double height)
{XYZ point1 = leftUpPoint;XYZ point2 = point1 - XYZ.BasisX * width;XYZ point3 = point2 - XYZ.BasisZ * height;XYZ point4 = point1 - XYZ.BasisZ * height;CurveLoop curveloop = new CurveLoop();Line line1 = Line.CreateBound(point1, point2);Line line2 = Line.CreateBound(point2, point3);Line line3 = Line.CreateBound(point3, point4);Line line4 = Line.CreateBound(point4, point1);curveloop.Append(line1);curveloop.Append(line2);curveloop.Append(line3);curveloop.Append(line4);return curveloop;
}

创建SketchPlane的代码

public void CreateSketchPlane(ExternalCommandData CommandData)
{ExternalCommandData externalCommandData = CommandData as ExternalCommandData;UIDocument uiDoc = externalCommandData.Application.ActiveUIDocument;Document rvtDoc = uiDoc.Document;using (Transaction tran = new Transaction(rvtDoc, "Create SketchPlane")){tran.Start();// 创建一个新的平面,这里以XY平面为例Plane plane = Plane.CreateByNormalAndOrigin(uiDoc.Document.ActiveView.ViewDirection, uiDoc.Document.ActiveView.Origin);// 使用Document对象创建一个新的SketchPlaneSketchPlane sketchPlane = SketchPlane.Create(rvtDoc, plane);sketchPlane.Name = rvtDoc.ActiveView.Name;rvtDoc.ActiveView.SketchPlane = sketchPlane;rvtDoc.ActiveView.ShowActiveWorkPlane();rvtDoc.Regenerate();tran.Commit();}
}

相关调用的代码

protected override Result OnExecute(ExternalCommandData commandData, ref string message, ElementSet elements)
{try{// 获取当前活动的文档UIDocument uiDoc = commandData.Application.ActiveUIDocument;Document rvtDoc = uiDoc.Document;View activeView = uiDoc.ActiveView;// 获取当前文档中的选择集Selection selection = uiDoc.Selection;CreateSketchPlane(commandData);// 捕捉鼠标位置XYZ mousePosition = selection.PickPoint("请点击鼠标位置");using (Transaction tran = new Transaction(rvtDoc, "Create FilledRegion")){tran.Start();var filter = new FilteredElementCollector(rvtDoc);var dates = filter.OfClass(typeof(GraphicsStyle)).ToElements();ElementId defaultTypeId = rvtDoc.GetDefaultElementTypeId(ElementTypeGroup.FilledRegionType);FilledRegionType filledRegionType = rvtDoc.GetElement(defaultTypeId) as FilledRegionType;//过滤填充图案FilteredElementCollector fillPatternFilter = new FilteredElementCollector(rvtDoc);fillPatternFilter.OfClass(typeof(FillPatternElement));//获取实体填充FillPatternElement fp = fillPatternFilter.First(m => (m as FillPatternElement).GetFillPattern().IsSolidFill) as FillPatternElement;double width = UnitUtils.ConvertToInternalUnits(350, DisplayUnitType.DUT_MILLIMETERS);double height = UnitUtils.ConvertToInternalUnits(350, DisplayUnitType.DUT_MILLIMETERS);//东立面//CurveLoop curvesLoop = GetEastCurveLoop(mousePosition, width, height);//西立面//CurveLoop curvesLoop = GetWestCurveLoop(mousePosition, width, height);//南立面//CurveLoop curvesLoop = GetSouthCurveLoop(mousePosition, width, height);//北立面CurveLoop curvesLoop = GetNorthCurveLoop(mousePosition, width, height);IList<CurveLoop> curves = new List<CurveLoop>();curves.Add(curvesLoop);FilledRegion filledRegion = FilledRegion.Create(rvtDoc, defaultTypeId, activeView.Id, curves);OverrideGraphicSettings ogs = activeView.GetElementOverrides(filledRegion.Id);设置 投影/表面 ->填充图案->填充图案ogs.SetProjectionFillPatternId(fp.Id);设置 投影/表面 ->填充图案->颜色ogs.SetProjectionFillColor(new Color(255, 0, 0));应用到视图activeView.SetElementOverrides(filledRegion.Id, ogs);tran.Commit();}return Result.Succeeded;}catch (Exception e){return Result.Failed;}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/504601.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

[计算机网络]--五种IO模型和select

前言 作者&#xff1a;小蜗牛向前冲 名言&#xff1a;我可以接受失败&#xff0c;但我不能接受放弃 如果觉的博主的文章还不错的话&#xff0c;还请点赞&#xff0c;收藏&#xff0c;关注&#x1f440;支持博主。如果发现有问题的地方欢迎❀大家在评论区指正 目录 一、五种IO…

【BUUCTF web】通关 2.0

&#x1f36c; 博主介绍&#x1f468;‍&#x1f393; 博主介绍&#xff1a;大家好&#xff0c;我是 hacker-routing &#xff0c;很高兴认识大家~ ✨主攻领域&#xff1a;【渗透领域】【应急响应】 【Java】 【VulnHub靶场复现】【面试分析】 &#x1f389;点赞➕评论➕收藏 …

Linux篇: 进程控制

一、进程创建 1.1 fork函数初识 在Linux中&#xff0c;fork函数是非常重要的函数&#xff0c;它从已存在进程中创建一个新进程。新进程为子进程&#xff0c;而原进程为父进程。 返回值&#xff1a; 在子进程中返回0&#xff0c;父进程中返回子进程的PID&#xff0c;子进程创…

Vue3快速上手(十六)Vue3路由传参大全

Vue3路由传参 一、传参的多种方式 1.1 拼接方式 这种方式适合传递单个参数的情况&#xff0c;比如点击查看详情&#xff0c;传个id这样的场景 传参&#xff1a; <RouterLink to"/person?id1" active-class"active">person</RouterLink> …

Linux高负载排查最佳实践

在Linux系统中&#xff0c;经常会因为负载过高导致各种性能问题。那么如何进行排查&#xff0c;其实是有迹可循&#xff0c;而且模式固定。 本次就来分享一下&#xff0c;CPU占用过高、磁盘IO占用过高的排查方法。 还是那句话&#xff0c;以最佳实践入手&#xff0c;真传一句话…

如何使用naive 做一个模态框的方式

1.我的问题使用了一个table 表格&#xff0c;在表格中设置俩个按钮 最后做出来的效果 <template><div><h1>测试文件</h1><!-- 表格 --><n-data-table :columns"columns" :data"data" :pagination"pagination" …

数独游戏(dfs)

代码注释如下 #include <iostream> using namespace std; const int N 10; bool col[N][N], rol[N][N], cell[3][3][N]; char g[N][N]; bool dfs(int x, int y) { //用bool这样在找到一个方案就可以迅速退出if(y 9) x, y 0; //若y超出边界&#xff0c;则第二…

蓝桥杯-单片机组基础5——外部中断与LED的控制(附小蜜蜂课程代码)

蓝桥杯单片机组备赛指南请查看这篇文章&#xff1a;戳此跳转蓝桥杯备赛指南文章 本文章针对蓝桥杯-单片机组比赛开发板所写&#xff0c;代码可直接在比赛开发板上使用。 型号&#xff1a;国信天长4T开发板&#xff08;绿板&#xff09;&#xff0c;芯片&#xff1a;IAP15F2K6…

KubeSphere平台安装系列之二【Linux单节点部署KubeSphere】(2/3)

**《KubeSphere平台安装系列》** 【Kubernetes上安装KubeSphere&#xff08;亲测–实操完整版&#xff09;】&#xff08;1/3&#xff09; 【Linux单节点部署KubeSphere】&#xff08;2/3&#xff09; 【Linux多节点部署KubeSphere】&#xff08;3/3&#xff09; **《KubeS…

linux系统Jenkins工具配置webhook自动部署

Jenkins工具webhook自动部署 webhook自动部署webhook的意义操作流程jenkins页面操作gitlab页面操作 webhook自动部署 webhook的意义 自动化部署&#xff1a;Webhook 可以在代码提交、合并请求或其他特定事件发生时自动触发 Jenkins 构建和部署任务&#xff0c;从而实现自动化…

shell自定义日志输出函数log

Background 在编写比较复杂的脚本时&#xff0c;需要输出相关日志信息&#xff0c;方便知悉脚本的执行情况以及问题的排查。 源码 log.sh # 自定义日志函数 function log(){if [[ $1 "i" || $1 "info" ]]; thenecho -ne "\033[1;34mINFO: \033[0m&…