当前位置:网站首页>Revit secondary development - cut view
Revit secondary development - cut view
2022-07-07 22:22:00 【Hey, hey, hey, hey, hey】
demand : Draw the section line manually , After drawing, switch to the section view just drawn .
( Provincial users then click to go to the view , Only the first automatic jump , If you adjust the sectioning box, it will no longer jump automatically )ps: There are really all kinds of needs , I'm basically speechless. .
be used DocumentChange Events and external events .
1、 stay DocumentChange Event to listen whether to create a finished cut plane ,
2、 Record the view after creation ID Use external events to convert to the section view just created .
External events
public class ViewHandler : IExternalEventHandler
{
public void Execute(UIApplication app)
{
if(Command.gbv_viewSectionid == null) return;
Document doc = app.ActiveUIDocument.Document;
ViewSection vs = doc.GetElement(Command.gbv_viewSectionid) as ViewSection;
app.ActiveUIDocument.ActiveView = vs;
}
public string GetName()
{
return "view";
}
}
command
class Command
{
public static ElementId gbv_viewSectionId=null;
private ExternalEvent viewEvevt=null;
private bool m_IsCreatedSection = false;
public Result Execute(ExternalCommandData command)
{
UIDocument uiDoc = command.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
View view = doc.ActiveView;
if(view == ViewTye.ThreeD)return Result.Cancelled;
ViewHandler handler = new ViewHandler();
viewEvent = ExternalEvent.Create(handler);
RevitCommandId commandId = RevitCommandId.LookupPostableCommandId(PostableCommand.Section);
command.Application.PostCommand(commandId);
command.Application.Application.DocumentChange+=Application_DocumentChange;
m_IsCreatedSection=true;
}
privte void Application_DocumentChange(object sender, DocumentChangeEventArgs e)
{
if(IsCreatedSection)
{
IsCreatedSection = false;
Document doc = e.GetDocument();
list<ElementId> lstEid = e.GetAddElementIds().ToList();
foreach(ElementId eid in lstEid)
{
ViewSection vs = doc.GetElement(eid) as ViewSection;
if(vs != null)
{
gbv_viewSectionid = eid;
if(viewEvent != null)
viewEvent.Raise();
break;
}
}
}
}
}
边栏推荐
- OpenGL homework - Hello, triangle
- 为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
- Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]
- Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda
- Jerry's configuration of TWS cross pairing [article]
- Add get disabled for RC form
- null == undefined
- OpeGL personal notes - lights
- Ternary expressions, generative expressions, anonymous functions
- How polardb-x does distributed database hotspot analysis
猜你喜欢
嵌入式开发:如何为项目选择合适的RTOS?
如何选择合适的自动化测试工具?
Cannot find module 'xxx' or its corresponding type declaration
Solve the problem of uni in uni app Request sent a post request without response.
Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
NVR hard disk video recorder is connected to easycvr through the national standard gb28181 protocol. What is the reason why the device channel information is not displayed?
UWA问答精选
Latest Android advanced interview questions summary, Android interview questions and answers
Two methods of calling WCF service by C #
Anti climbing killer
随机推荐
ByteDance Android interview, summary of knowledge points + analysis of interview questions
How does win11 unblock the keyboard? Method of unlocking keyboard in win11
Redis - basic use (key, string, list, set, Zset, hash, geo, bitmap, hyperloglog, transaction)
Pdf document signature Guide
Ad domain group policy management
【JDBC Part 1】概述、获取连接、CRUD
Talk about relational database and serverless
OpenGL jobs - shaders
Programming mode - table driven programming
应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
operator
怎样写一个增广矩阵到txt文件中
Reinforcement learning - learning notes 9 | multi step TD target
Jerry's power on automatic pairing [chapter]
Firefox browser installation impression notes clipping
Win11游戏模式怎么开启?Win11开启游戏模式的方法
Jerry's test box configuration channel [chapter]
Jerry's fast pairing does not support canceling pairing [article]
#DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
Remove the default background color of chrome input input box