本文整理汇总了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;
}
}
示例2: Execute
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements )
{
return Result.Succeeded;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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);
}
示例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;
}