// 跟随鼠标拖动效果 [Transaction(TransactionMode.Manual)][Regeneration(RegenerationOption.Manual)] public class DragElement : IExternalCommand{ public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements) { UIDocument uiDoc = cmdData.Application.ActiveUIDocument; FilteredElementCollector collector = new FilteredElementCollector(uiDoc.Document); IList < Element > collection = collector.OfClass( typeof (FamilySymbol)).OfCategory(BuiltInCategory.OST_DuctFitting).ToElements(); FamilySymbol familySymbol = collection[ 0 ] as FamilySymbol; uiDoc.PromptForFamilyInstancePlacement(familySymbol); // 重点。进入布置管件状态 return Result.Succeeded; }}