当前位置:网站首页>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;
}
}
}
}
}
边栏推荐
- Programming mode - table driven programming
- [colmap] sparse reconstruction is converted to mvsnet format input
- Relationship between URL and URI
- Use json Stringify() to realize deep copy, be careful, there may be a huge hole
- [开源] .Net ORM 访问 Firebird 数据库
- 应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
- Restapi version control strategy [eolink translation]
- Open source OA development platform: contract management user manual
- How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525
- How polardb-x does distributed database hotspot analysis
猜你喜欢
Jerry's about TWS pairing mode configuration [chapter]
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
ByteDance Android interview, summary of knowledge points + analysis of interview questions
Paint basic graphics with custompaint
The strongest installation of the twin tower model, Google is playing "antique" again?
Matplotlib快速入门
Jerry's manual matching method [chapter]
TCP/IP 协议栈
Two methods of calling WCF service by C #
vite Unrestricted file system access to
随机推荐
嵌入式开发:如何为项目选择合适的RTOS?
How to close eslint related rules
Welcome to CSDN markdown editor
How does win11 time display the day of the week? How does win11 display the day of the week today?
Win11如何解禁键盘?Win11解禁键盘的方法
Jerry's key to initiate pairing [chapter]
海外代理推荐
Firefox browser installation impression notes clipping
客户案例|华律网,通过观测云大幅缩短故障定位时间
Win11时间怎么显示星期几?Win11怎么显示今天周几?
#DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
Reinforcement learning - learning notes 9 | multi step TD target
EasyCVR配置中心录像计划页面调整分辨率时的显示优化
Crawler (17) - Interview (2) | crawler interview question bank
Embedded development: how to choose the right RTOS for the project?
Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
使用 BlocConsumer 同时构建响应式组件和监听状态
UWA问答精选
Attitude estimation (complementary filtering)
Get the exact offset of the element