[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmd : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
UIApplication uiApp = cmdData.Application;
Document doc = uiDoc.Document;
Selection selection = uiDoc.Selection;
Transaction ts = new Transaction(doc, " http://revit.5d6d.com ");
ts.Start();
FilteredElementCollector collector = new FilteredElementCollector(doc); //
collector.OfClass( typeof(Instance)).OfCategory(BuiltInCategory.OST_RvtLinks); // RevitLinkType
foreach (Element elLink in collector)
{
Instance ins = elLink as Instance;
RevitLinkType linkType = doc.get_Element(ins.GetTypeId()) as RevitLinkType;
Parameter p = linkType.get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING);
p.Set( 1); // 设置房间边界
}
ts.Commit();
return Result.Succeeded;
}
/// <summary>
/// 取得链接文件路径
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public List< string> GetLinkFilePaths(Document doc)
{
List< string> listPath = new List< string>();
foreach (ElementId elId in ExternalFileUtils.GetAllExternalFileReferences(doc))
{
if (doc.get_Element(elId).IsExternalFileReference())
{
ExternalFileReference fileRef = doc.get_Element(elId).GetExternalFileReference();
if (ExternalFileReferenceType.RevitLink == fileRef.ExternalFileReferenceType)
listPath.Add(ModelPathUtils.ConvertModelPathToUserVisiblePath(fileRef.GetAbsolutePath()));
}
}
return listPath;
}
}
[Regeneration(RegenerationOption.Manual)]
public class cmd : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
UIApplication uiApp = cmdData.Application;
Document doc = uiDoc.Document;
Selection selection = uiDoc.Selection;
Transaction ts = new Transaction(doc, " http://revit.5d6d.com ");
ts.Start();
FilteredElementCollector collector = new FilteredElementCollector(doc); //
collector.OfClass( typeof(Instance)).OfCategory(BuiltInCategory.OST_RvtLinks); // RevitLinkType
foreach (Element elLink in collector)
{
Instance ins = elLink as Instance;
RevitLinkType linkType = doc.get_Element(ins.GetTypeId()) as RevitLinkType;
Parameter p = linkType.get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING);
p.Set( 1); // 设置房间边界
}
ts.Commit();
return Result.Succeeded;
}
/// <summary>
/// 取得链接文件路径
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
public List< string> GetLinkFilePaths(Document doc)
{
List< string> listPath = new List< string>();
foreach (ElementId elId in ExternalFileUtils.GetAllExternalFileReferences(doc))
{
if (doc.get_Element(elId).IsExternalFileReference())
{
ExternalFileReference fileRef = doc.get_Element(elId).GetExternalFileReference();
if (ExternalFileReferenceType.RevitLink == fileRef.ExternalFileReferenceType)
listPath.Add(ModelPathUtils.ConvertModelPathToUserVisiblePath(fileRef.GetAbsolutePath()));
}
}
return listPath;
}
}