public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { m_application = commandData.Application.Application; m_document = commandData.Application.ActiveUIDocument.Document; if (!m_document.IsFamilyDocument) { message = "无法在非族类文档中使用"; return(Result.Failed); } m_appCreator = m_application.Create; m_familyCreator = m_document.FamilyCreate; Transaction trans = new Transaction(m_document); trans.Start("创建新曲线"); MakeNewCurve(); //commandData.Application.ActiveUIDocument.Selection.PickPoint trans.Commit(); } catch (Exception ex) { message = ex.ToString(); return(Result.Failed); } return(Result.Succeeded); }
Stream(ArrayList data, ItemFactoryBase itemFactBase) { data.Add(new Snoop.Data.ClassSeparator(typeof(ItemFactoryBase))); // No data at this level yet! FamilyItemFactory famItem = itemFactBase as FamilyItemFactory; if (famItem != null) { Stream(data, famItem); return; } }
/// <summary> /// Implement this method as an external command for Revit. /// </summary> /// <param name="commandData">An object that is passed to the external application /// which contains data related to the command, /// such as the application object and active view.</param> /// <param name="message">A message that can be set by the external application /// which will be displayed if a failure or cancellation is returned by /// the external command.</param> /// <param name="elements">A set of elements to which the external application /// can add elements that are to be highlighted in case of failure or cancellation.</param> /// <returns>Return the status of the external command. /// A result of Succeeded means that the API external method functioned as expected. /// Cancelled can be used to signify that the user cancelled the external operation /// at some point. Failure should be returned if the application is unable to proceed with /// the operation.</returns> public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { // set out default result to failure. Autodesk.Revit.UI.Result retRes = Autodesk.Revit.UI.Result.Failed; m_application = commandData.Application.Application; m_document = commandData.Application.ActiveUIDocument.Document; f = m_document.FamilyCreate; extrusions = new Extrusion[5]; m_combineElements = new CombinableElementArray(); m_transaction = new Transaction(m_document, "External Tool"); m_transaction.Start(); if (m_document.OwnerFamily.FamilyCategory.Name != m_document.Settings.Categories.get_Item(BuiltInCategory.OST_MechanicalEquipment).Name) // FamilyCategory.Name is not "Mechanical Equipment". { message = "Please make sure you opened a template of Mechanical Equipment."; return(retRes); } try { CreateExtrusions(); m_document.Regenerate(); CreateConnectors(); m_document.Regenerate(); m_document.CombineElements(m_combineElements); m_document.Regenerate(); } catch (Exception x) { m_transaction.RollBack(); message = x.Message; return(retRes); } m_transaction.Commit(); retRes = Autodesk.Revit.UI.Result.Succeeded; return(retRes); }
Stream(ArrayList data, FamilyItemFactory famItem) { data.Add(new Snoop.Data.ClassSeparator(typeof(FamilyItemFactory))); // No data at this level yet! }
private void Stream(ArrayList data, FamilyItemFactory famItem) { data.Add(new Snoop.Data.ClassSeparator(typeof(FamilyItemFactory))); // No data at this level yet! }
/// <summary> /// Implement this method as an external command for Revit. /// </summary> /// <param name="commandData">An object that is passed to the external application /// which contains data related to the command, /// such as the application object and active view.</param> /// <param name="message">A message that can be set by the external application /// which will be displayed if a failure or cancellation is returned by /// the external command.</param> /// <param name="elements">A set of elements to which the external application /// can add elements that are to be highlighted in case of failure or cancellation.</param> /// <returns>Return the status of the external command. /// A result of Succeeded means that the API external method functioned as expected. /// Cancelled can be used to signify that the user cancelled the external operation /// at some point. Failure should be returned if the application is unable to proceed with /// the operation.</returns> public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { // set out default result to failure. Autodesk.Revit.UI.Result retRes = Autodesk.Revit.UI.Result.Failed; m_application = commandData.Application.Application; m_document = commandData.Application.ActiveUIDocument.Document; f = m_document.FamilyCreate; extrusions = new Extrusion[5]; m_combineElements = new CombinableElementArray(); m_transaction = new Transaction(m_document, "External Tool"); m_transaction.Start(); if (m_document.OwnerFamily.FamilyCategory.Name != "Mechanical Equipment") { message = "Please make sure you opened a template of Mechanical Equipment."; return retRes; } try { CreateExtrusions(); m_document.Regenerate(); CreateConnectors(); m_document.Regenerate(); m_document.CombineElements(m_combineElements); m_document.Regenerate(); } catch(Exception x) { m_transaction.RollBack(); message = x.Message; return retRes; } m_transaction.Commit(); retRes = Autodesk.Revit.UI.Result.Succeeded; return retRes; }