Hey!
It looks like It can be done by Dynamo. Have you tried using Dynamo for this situation?
I'm not familiar with Dynamo. Would using PyRevit make it more convenient to achieve this?
I am not an expert on pyRevit but, I could not find a way to tag elements in selected views by using pyRevit.
I am leaving a link for you to explore your options.
Hi @liuhaohao970705 :
使用c#可以使用下面代码,遍历每个视图并且应用多类别注释添加
using (Transaction transaction= new Transaction(doc))
{
transaction.Start("TT");
var collector = new FilteredElementCollector(doc);
var views = collector.OfClass(typeof(View)).OfCategory(BuiltInCategory.OST_Views).Cast<View>().Where(v=>
(v.ViewType == ViewType.EngineeringPlan || v.ViewType == ViewType.FloorPlan) && v.CanBePrinted);
foreach (var view in views)
{
var instances = new FilteredElementCollector(doc, view.Id).WhereElementIsNotElementType()
.Where(x => x.GetType() == typeof(FamilyInstance) || x.GetType() == typeof(Pipe))
.ToList();
foreach (Element instance in instances)
{
var reference = new Reference(instance);
IndependentTag.Create(doc,view.Id,reference,true,TagMode.TM_ADDBY_MULTICATEGORY,TagOrientation.Vertical,XYZ.Zero);
}
}
transaction.Commit();
}
LanHui Xu
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Hi @liuhaohao970705 :
我测试了一下代码,增加了视图裁剪并且修改了边界,视图之外的没有添加标记,您那边出现标记是什么族类别或者批注之后的截图可以上传吗?
LanHui Xu
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Hi @liuhaohao970705 :
目前没有什么好的办法去获得遮挡构件,或者通过其他运算获得,如果你用Dynamo的话可以找一下直接调用Revit命令的按钮,promptcommand这个命令,多类别标记的命令是` ID_BUTTON_TAG_ALL`,每个视图运行一次也可以完成这个操作
RevitCommandId id = RevitCommandId.LookupCommandId("Command命令");
if (uiApplication.CanPostCommand(id))
{
uiApplication.PostCommand(id);
}
···
LanHui Xu
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.