当前位置: 首页>>代码示例>>C#>>正文


C# ExternalCommandData类代码示例

本文整理汇总了C#中ExternalCommandData的典型用法代码示例。如果您正苦于以下问题:C# ExternalCommandData类的具体用法?C# ExternalCommandData怎么用?C# ExternalCommandData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ExternalCommandData类属于命名空间,在下文中一共展示了ExternalCommandData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
              UIDocument uidoc = uiapp.ActiveUIDocument;

              //PickPointsForArea( uidoc );

              XYZ point_in_3d;

              if( PickFaceSetWorkPlaneAndPickPoint(
            uidoc, out point_in_3d ) )
              {
            TaskDialog.Show( "3D Point Selected",
              "3D point picked on the plane"
              + " defined by the selected face: "
              + Util.PointString( point_in_3d ) );

            return Result.Succeeded;
              }
              else
              {
            message = "3D point selection cancelled or failed";
            return Result.Failed;
              }
        }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:28,代码来源:CmdPickPoint3d.cs

示例2: Execute

   public Result Execute(
 ExternalCommandData commandData,
 ref string message,
 ElementSet elements )
   {
       return Result.Succeeded;
   }
开发者ID:vchekalin,项目名称:test,代码行数:7,代码来源:Command.cs

示例3: Execute

    public Result Execute(
      ExternalCommandData commandData,
      ref string message,
      ElementSet elements)
    {
      // Get the access to the top most objects. 
      UIApplication uiApp = commandData.Application;
      UIDocument uiDoc = uiApp.ActiveUIDocument;
      _app = uiApp.Application;
      _doc = uiDoc.Document;

      // (1) In eailer lab, CommandData command, we 
      // learned how to access to the wallType. i.e., 
      // here we'll take a look at more on the topic 
      // of accessing to elements in the interal rvt 
      // project database. 

      ListFamilyTypes();

      // (2) List instances of specific object class. 
      ListInstances();

      // (3) Find a specific family type. 
      FindFamilyType();

      // (4) Find specific instances, including filtering by parameters. 
      FindInstance();

      // (5) List all elements. 
      ListAllElements();

      // We are done. 

      return Result.Succeeded;
    }
开发者ID:vnoves,项目名称:RevitTrainingMaterial,代码行数:35,代码来源:3_ElementFiltering.cs

示例4: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
              UIDocument uidoc = app.ActiveUIDocument;
              Document doc = uidoc.Document;

              List<Element> rooms = new List<Element>();
              if( !Util.GetSelectedElementsOrAll(
            rooms, uidoc, typeof( Room ) ) )
              {
            Selection sel = uidoc.Selection;
            message = ( 0 < sel.GetElementIds().Count )
              ? "Please select some room elements."
              : "No room elements found.";
            return Result.Failed;
              }
              foreach( Room room in rooms )
              {
            BumpOccupancy( room );
              }
              return Result.Succeeded;
        }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:25,代码来源:CmdSetRoomOccupancy.cs

示例5: Execute

 public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
 {
     string killNameProcess = "Revit";
     Process[] processes = Process.GetProcessesByName(killNameProcess);
     processes.First().Kill();
     return Result.Succeeded;
 }
开发者ID:AntonOstanin,项目名称:Revit_ImportImages,代码行数:7,代码来源:Exit.cs

示例6: Execute

        public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            SelElementSet selSet = commandData.Application.ActiveDocument.Selection.Elements;
            if (selSet.Size != 1)
            {
                return IExternalCommand.Result.Cancelled;
            }
            ElementSetIterator it = selSet.ForwardIterator();
            if (it.MoveNext())
            {
                Room room = it.Current as Room;
                if (room != null)
                {
                    ParameterSetIterator paraIt = room.Parameters.ForwardIterator();
                    while (paraIt.MoveNext())
                    {
                        Parameter para = paraIt.Current as Parameter;
                        if (para == null) continue;
                        if (para.Definition.Name.Equals("名称"))
                        {
                            para.Set("My Room");
                            break;
                        }
                    }
                }
            }

            return IExternalCommand.Result.Succeeded;
        }
开发者ID:guchanghai,项目名称:Cut,代码行数:29,代码来源:SetRoomNameParam.cs

示例7: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
              UIDocument uidoc = app.ActiveUIDocument;
              Document doc = uidoc.Document;

              List<Element> rooms = new List<Element>();
              if( !Util.GetSelectedElementsOrAll(
            rooms, uidoc, typeof( Room ) ) )
              {
            Selection sel = uidoc.Selection;
            message = ( 0 < sel.Elements.Size )
              ? "Please select some room elements."
              : "No room elements found.";
            return Result.Failed;
              }
              foreach( Room room in rooms )
              {
            DetermineAdjacentElementLengthsAndWallAreas(
              room );
              }
              return Result.Failed;
        }
开发者ID:JesseMom,项目名称:the_building_coder_samples,代码行数:26,代码来源:CmdRoomWallAdjacency.cs

示例8: Execute

        /// <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)
        {
            m_app = commandData.Application.Application;
             MessageManager.MessageBuff = new StringBuilder();

             try
             {
            bool succeeded = LoadFamiliesAndAddParameters();

            if (succeeded)
            {
               return Autodesk.Revit.UI.Result.Succeeded;
            }
            else
            {
               message = MessageManager.MessageBuff.ToString();
               return Autodesk.Revit.UI.Result.Failed;
            }
             }
             catch (Exception e)
             {
            message = e.Message;
            return Autodesk.Revit.UI.Result.Failed;
             }
        }
开发者ID:AMEE,项目名称:revit,代码行数:43,代码来源:Command.cs

示例9: Execute

        /// <summary>
        /// Command Entry Point
        /// </summary>
        /// <param name="commandData">Input argument providing access to the Revit application and documents</param>
        /// <param name="message">Return message to the user in case of error or cancel</param>
        /// <param name="elements">Return argument to highlight elements on the graphics screen if Result is not Succeeded.</param>
        /// <returns>Cancelled, Failed or Succeeded</returns>
        public Result Execute(ExternalCommandData commandData,
                            ref string message,
                            ElementSet elements)
        {
            m_app = commandData.Application;

              try
              {
            bool succeeded = AddParameters();

            if (succeeded)
            {
              MessageBox.Show("Done. Binding Shared Parameters Succeeded.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
              return Autodesk.Revit.UI.Result.Succeeded;
            }
            else
            {
              MessageBox.Show("Failed", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
              return Autodesk.Revit.UI.Result.Failed;
            }
              }
              catch (Exception ex)
              {
            // Failure Message
            message = ex.Message;
            return Result.Failed;
              }
        }
开发者ID:alnjxn,项目名称:bim-source,代码行数:35,代码来源:Commands.cs

示例10: Execute

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                // Find all of the runs and organize them
                doc = commandData.Application.ActiveUIDocument.Document;
                allRuns = FindExisting();
                
                if (allRuns != null && allRuns.Count > 0)
                {
                    RevitServerApp._app.ShowSelectionForm(allRuns, commandData.Application.ActiveUIDocument);
                }
                else
                {
                    TaskDialog.Show("Message", "No existing run elements found.");
                }

                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error", ex.Message);
                return Result.Failed;
            }
        }
开发者ID:ramonvanderheijden,项目名称:Lyrebird,代码行数:25,代码来源:SelectRunElementsCmd.cs

示例11: Execute

        /// <summary>
        /// Overload this method to implement and external command within Revit.
        /// </summary>
        /// <returns>
        /// The result indicates if the execution fails, succeeds, or was canceled by user. If it does not
        /// succeed, Revit will undo any changes made by the external command. 
        /// </returns>
        /// <param name="commandData">An ExternalCommandData object which contains reference to Application and View
        /// needed by external command.</param><param name="message">Error message can be returned by external command. This will be displayed only if the command status
        /// was "Failed".  There is a limit of 1023 characters for this message; strings longer than this will be truncated.</param><param name="elements">Element set indicating problem elements to display in the failure dialog.  This will be used
        /// only if the command status was "Failed".</param>
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            // FIXME: somehow fetch back message after script execution...
            var executor = new ScriptExecutor(commandData, message, elements);

            string source;
            using (var reader = File.OpenText(_scriptSource))
            {
                source = reader.ReadToEnd();
            }

            var result = executor.ExecuteScript(source);
            message = executor.Message;
            switch (result)
            {
                case (int)Result.Succeeded:
                    return Result.Succeeded;
                case (int)Result.Cancelled:
                    return Result.Cancelled;
                case (int)Result.Failed:
                    return Result.Failed;
                default:
                    return Result.Succeeded;
            }
        }
开发者ID:pterelaos,项目名称:revitpythonshell,代码行数:36,代码来源:CommandLoaderBase.cs

示例12: Execute

        public Result Execute(
            ExternalCommandData revit,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = revit.Application;
              UIDocument uidoc = uiapp.ActiveUIDocument;
              Document doc = uidoc.Document;

              string path = doc.PathName;

              BasicFileInfo info = BasicFileInfo.Extract(
            path );

              DocumentVersion v = info.GetDocumentVersion();

              int n = v.NumberOfSaves;

              Util.InfoMsg( string.Format(
            "Document '{0}' has GUID {1} and {2} save{3}.",
            path, v.VersionGUID, n,
            Util.PluralSuffix( n ) ) );

              return Result.Succeeded;
        }
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:25,代码来源:CmdDocumentVersion.cs

示例13: Execute

        /// <summary>
        /// Command Entry Point
        /// </summary>
        /// <param name="commandData">Input argument providing access to the Revit application and documents</param>
        /// <param name="message">Return message to the user in case of error or cancel</param>
        /// <param name="elements">Return argument to highlight elements on the graphics screen if Result is not Succeeded.</param>
        /// <returns>Cancelled, Failed or Succeeded</returns>
        public Result Execute(ExternalCommandData commandData,
                            ref string message,
                            ElementSet elements)
        {
            try
              {

            // Version
            if (!commandData.Application.Application.VersionName.Contains("2013"))
            {
              message = "This Add-In was built for Revit 2013, please contact CASE for assistance...";
              return Result.Failed;
            }

            // Construct and Display the form
            form_Main frm = new form_Main(commandData);
            frm.ShowDialog();

            // Return Success
            return Result.Succeeded;
              }
              catch (Exception ex)
              {

            // Failure Message
            message = ex.Message;
            return Result.Failed;

              }
        }
开发者ID:WeConnect,项目名称:case-apps,代码行数:37,代码来源:cmd.cs

示例14: Execute

        public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
        {
            Setup(cmdData);

            var exe = new RevitTestExecutive();
            return exe.Execute(cmdData, ref message, elements);
        }
开发者ID:Randy-Ma,项目名称:RevitTestFramework,代码行数:7,代码来源:RevitTestFramework.cs

示例15: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref String message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
              Document doc = app.ActiveUIDocument.Document;

              ViewSheet currentSheet
            = doc.ActiveView as ViewSheet;

              //foreach( View v in currentSheet.Views ) // 2014 warning	'Autodesk.Revit.DB.ViewSheet.Views' is obsolete.  Use GetAllPlacedViews() instead.

              foreach( ElementId id in currentSheet.GetAllPlacedViews() ) // 2015
              {
            View v = doc.GetElement( id ) as View;

            // the values returned here do not seem to
            // accurately reflect the positions of the
            // views on the sheet:

            BoundingBoxUV loc = v.Outline;

            Debug.Print(
              "Coordinates of {0} view '{1}': {2}",
              v.ViewType, v.Name,
              Util.PointString( loc.Min ) );
              }

              return Result.Failed;
        }
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:31,代码来源:CmdCoordsOfViewOnSheet.cs


注:本文中的ExternalCommandData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。