[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
// [Journaling(JournalingMode.NoCommandData)]
public class SetDefaultFamilySymbol : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application;
Transaction ts = new Transaction(uiDoc.Document, " test " );
ts.Start();
HyRevit.Key.Press.Keys( " DT " ); // 调用Revit画风管的命令
FilteredElementCollector collector = new FilteredElementCollector(uiDoc.Document);
collector.OfClass( typeof (DuctType)).OfCategory(BuiltInCategory.OST_DuctCurves);
IList < Element > list = collector.ToElements();
FamilySymbol fi = null ;
foreach (Element el in list)
{
if (el.Name == " Tees " )
fi = el as FamilySymbol;
}
if (fi != null )
uiDoc.PromptForFamilyInstancePlacement(fi);
ts.Commit();
return Autodesk.Revit.UI.Result.Succeeded;
}
}
[Regeneration(RegenerationOption.Manual)]
// [Journaling(JournalingMode.NoCommandData)]
public class SetDefaultFamilySymbol : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = commandData.Application.Application;
Transaction ts = new Transaction(uiDoc.Document, " test " );
ts.Start();
HyRevit.Key.Press.Keys( " DT " ); // 调用Revit画风管的命令
FilteredElementCollector collector = new FilteredElementCollector(uiDoc.Document);
collector.OfClass( typeof (DuctType)).OfCategory(BuiltInCategory.OST_DuctCurves);
IList < Element > list = collector.ToElements();
FamilySymbol fi = null ;
foreach (Element el in list)
{
if (el.Name == " Tees " )
fi = el as FamilySymbol;
}
if (fi != null )
uiDoc.PromptForFamilyInstancePlacement(fi);
ts.Commit();
return Autodesk.Revit.UI.Result.Succeeded;
}
}