转载请复制以下信息:
原文链接: http://blog.csdn.net/joexiongjin/article/details/7433087
作者: 叶雄进
2012.4.6
有开发者问到如何创建视图样式对象。这篇文章与之前我写的对象创建技巧这篇文章使用的相同的技巧,使用类型对象的Duplicate() 方法。请参看如下链接。
http://blog.csdn.net/joexiongjin/article/details/7213424
视图样式对象在Revit中是用ElementType这个类来代表的。我们同样可以用上面的方法创建。
下面是参考代码。为了快速举例,这里使用了一个模型中现有视图的Id来获得视图对象,然后从视图对象获得视图样式对象。实际用时请替换
ElementId id = new ElementId(70040);
这行代码
//please assign doc value here.
//Here 70040 represents a existing Structural plan view. you need to replace this line by the code getting the target structural plan view.
ElementId id = new ElementId(70040);
Transaction trans = new Transaction(doc);
trans.Start("CreateViewType");
ViewPlan view = doc.get_Element(id) as ViewPlan;
ElementId typeId = view.GetTypeId();
ElementType type = doc.get_Element(typeId) as ElementType;
ElementType newType = type.Duplicate("Joe Test");
trans.Commit();
本文主要是想表达可以编程创建试图样式对象。