当前位置:网站首页>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;
}
}
}
}
}
边栏推荐
- Matplotlib快速入门
- Px4 autonomous flight
- Firefox browser installation impression notes clipping
- Ternary expressions, generative expressions, anonymous functions
- vite Unrestricted file system access to
- Index summary (assault version)
- The essence of analog Servlet
- It's worth seeing. Interview sites and interview skills
- Jerry's key to initiate pairing [chapter]
- Jerry's configuration of TWS cross pairing [article]
猜你喜欢
Redis - basic use (key, string, list, set, Zset, hash, geo, bitmap, hyperloglog, transaction)
It's worth seeing. Interview sites and interview skills
Anti climbing killer
Px4 autonomous flight
How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525
Node:504 error reporting
使用 BlocConsumer 同时构建响应式组件和监听状态
建立自己的网站(18)
The latest Android interview collection, Android video extraction audio
三元表达式、各生成式、匿名函数
随机推荐
How to close eslint related rules
It's worth seeing. Interview sites and interview skills
Jerry's key to initiate pairing [chapter]
EasyCVR配置中心录像计划页面调整分辨率时的显示优化
The whole network "chases" Zhong Xuegao
Pdf document signature Guide
Index summary (assault version)
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
How does win11 unblock the keyboard? Method of unlocking keyboard in win11
Oracle advanced (VI) Oracle expdp/impdp details
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
Tcp/ip protocol stack
Main functions of OS, Sys and random Standard Libraries
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?
Can I open a stock account directly online now? Is it safe?
Jerry's manual matching method [chapter]
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
Matplotlib drawing interface settings
[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster
双塔模型的最强出装,谷歌又开始玩起“老古董”了?