[英]Copy dimensions from a View to another Revit API
I'm trying to create a new plug-in on Revit 2016/2017 with the API. 我正在尝试使用API在Revit 2016/2017上创建一个新插件。 The idea is to copy a set of element from small revit file to a central one to compile them.
这个想法是将一组元素从小的revit文件复制到一个中央元素进行编译。
Here is the code I'm using : 这是我正在使用的代码:
FilterableValueProvider provider = new ParameterValueProvider(new ElementId(BuiltInParameter.ALL_MODEL_TYPE_NAME));
FilterRule rule = new FilterStringRule(provider, new FilterStringContains(), "BY_GO", false);
ElementParameterFilter epf = new ElementParameterFilter(rule, true);
ICollection<ElementId> npText = new FilteredElementCollector(secDoc, secView.Id).WherePasses(epf).ToElementIds();
using (TransactionGroup tx = new TransactionGroup(mainDoc, "Insert " + Main._roomFile.Typology))
{
ICollection<ElementId> pastedElements;
tx.Start();
using (Transaction tr = new Transaction(mainDoc, "Copy elements"))
{
tr.Start();
pastedElements = ElementTransformUtils.CopyElements(secView, npText, mainView, null, new CopyPasteOptions());
tr.Commit();
}
using (Transaction tr = new Transaction(mainDoc, "Move elements"))
{
tr.Start();
pastedElements = new FilteredElementCollector(mainDoc, pastedElements).WherePasses(epf).ToElementIds();
XYZ originePoint = new FilteredElementCollector(mainDoc, pastedElements).OfClass(typeof(Floor)).First().get_BoundingBox(null).Min;
XYZ translation = extremitePoint - originePoint;
translation = new XYZ(translation.X, translation.Y, 0);
ElementTransformUtils.MoveElements(mainDoc, pastedElements, translation);
tr.Commit();
}
tx.Assimilate();
}
When I use it, everything is good except the dimensions. 当我使用它时,除尺寸外,其他一切都很好。 They are inside the new document (I can get them with there id and RevitLookup) but they are hidden.
它们位于新文档中(我可以通过id和RevitLookup获取它们),但是它们是隐藏的。 If I select on of them and add a witness line the dimension is now visible again.
如果我选择其中一个并添加见证行,则尺寸现在又可见。 I tried to close and reopen Revit and place the vien on a sheet bt nothing.
我试图关闭然后重新打开Revit,然后将Vien放在纸上,什么也没有。
Any idea ? 任何想法 ?
Thank you ! 谢谢 !
You need to regenerate the view I believe. 您需要重新生成我相信的观点。
Try adding: 尝试添加:
Document.Regenerate();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.