当前位置:网站首页>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;
}
}
}
}
}
边栏推荐
- The latest Android interview collection, Android video extraction audio
- How to realize the movement control of characters in horizontal game
- 【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
- How does win11 unblock the keyboard? Method of unlocking keyboard in win11
- 谈谈制造企业如何制定敏捷的数字化转型策略
- How to close eslint related rules
- PKPM 2020软件安装包下载及安装教程
- 如何选择合适的自动化测试工具?
- EasyCVR配置中心录像计划页面调整分辨率时的显示优化
- Interview question 01.02 Determine whether it is character rearrangement - auxiliary array algorithm
猜你喜欢
如何选择合适的自动化测试工具?
Index summary (assault version)
【JDBC Part 1】概述、获取连接、CRUD
UWA问答精选
The function is really powerful!
ByteDance Android interview, summary of knowledge points + analysis of interview questions
Win11游戏模式怎么开启?Win11开启游戏模式的方法
L2: current situation, prospects and pain points of ZK Rollup
Matplotlib drawing interface settings
An in-depth understanding of fp/fn/precision/recall
随机推荐
How to realize the movement control of characters in horizontal game
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
Xcode modifies the default background image of launchscreen and still displays the original image
Matplotlib drawing interface settings
使用 CustomPaint 绘制基本图形
DNS series (I): why does the updated DNS record not take effect?
TCP/IP 协议栈
This experimental syntax requires enabling the parser plugin: ‘optionalChaining‘
应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
SAR影像质量评估
Write in front -- Talking about program development
operator
Win11时间怎么显示星期几?Win11怎么显示今天周几?
How to make agile digital transformation strategy for manufacturing enterprises
Crawler (17) - Interview (2) | crawler interview question bank
The free styling service of Dyson's official direct store is now open for appointment. Pioneer Technology interprets the styling concept of hair care and helps consumers unlock diversified and shiny s
谈谈制造企业如何制定敏捷的数字化转型策略
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
100million single men and women "online dating", supporting 13billion IPOs
EasyCVR配置中心录像计划页面调整分辨率时的显示优化