当前位置:网站首页>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;
}
}
}
}
}
边栏推荐
- Anti climbing killer
- Which financial products will yield high returns in 2022?
- ByteDance senior engineer interview, easy to get started, fluent
- 用语雀写文章了,功能真心强大!
- Antd date component appears in English
- null == undefined
- Overseas agent recommendation
- [azure microservice service fabric] how to transfer seed nodes in the service fabric cluster
- How to write an augmented matrix into TXT file
- What is the difference between the three values of null Nan undefined in JS
猜你喜欢
L2: current situation, prospects and pain points of ZK Rollup
Ternary expressions, generative expressions, anonymous functions
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
Jerry's test box configuration channel [chapter]
PDF文档签名指南
如何选择合适的自动化测试工具?
L'enregistreur de disque dur NVR est connecté à easycvr par le Protocole GB 28181. Quelle est la raison pour laquelle l'information sur le canal de l'appareil n'est pas affichée?
Build your own website (18)
OpenGL configuration vs2019
Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda
随机推荐
OpenGL job - texture
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
如何选择合适的自动化测试工具?
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
How to realize the movement control of characters in horizontal game
NVR硬盤錄像機通過國標GB28181協議接入EasyCVR,設備通道信息不顯示是什麼原因?
Overseas agent recommendation
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
Remove the default background color of chrome input input box
How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525
Talk about relational database and serverless
Have you ever been confused? Once a test / development programmer, ignorant gadget C bird upgrade
Write in front -- Talking about program development
Blender exchange group, welcome to the water group ~
Antd date component appears in English
SAR image quality evaluation
The strongest installation of the twin tower model, Google is playing "antique" again?
Two methods of calling WCF service by C #
Node:504 error reporting