PreviewControl 是一个WPF的自定义控件,这个控件可以用来在
Revit界面外显示Document的某个视图
它的构造函数需要传入 Document,和view 的Id
public PreviewControl( Document document, ElementId viewId )
它是从UserControl继承而来,所有可以当做WpF控件来使用
public class PreviewControl : UserControl, IDisposable
下面是一个简单例子:
public void PreViewW() { PreViewWin myWin = new PreViewWin(app); myWin.ShowDialog(); }
public partial class PreViewWin : Window { UIApplication uiapp = null; Autodesk.Revit.ApplicationServices.Application app = null; Document doc = null; public PreViewWin() { InitializeComponent(); } public PreViewWin(Autodesk.Revit.ApplicationServices.Application app) { InitializeComponent(); this.app = app; uiapp = new UIApplication(app); doc = uiapp.ActiveUIDocument.Document; PreviewControl pre = new PreviewControl(doc, doc.ActiveView.Id); this.grid.Children.Add(pre); } }
<Window x:Class="Revit2016Commands.PreViewWin" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:control ="clr-namespace:Autodesk.Revit.UI" Title="PreViewWin" Height="300" Width="300"> <Grid Name="grid"> </Grid> </Window>
博主会经常更新一些技术文章,请大家多多关注,多多交流
更多技术交流,请加qq群480950299