Results 1 to 2 of 2

Thread: Problem with Revit's external command

  1. #1
    Login to Give a bone
    0

    Default Problem with Revit's external command

    Hello All,
    I'm getting stuck when build an application UI, everything works perfect when I build the code, but when Revit opened and when run the plugin there is an error window titled Command Failure for External Command came up saying "Revit could not complete the external command. Contact the provider for assistance. Information they provided to Revit about their identity:."
    Is there anoyone here knows where is the mistake or knows the solution for this?

    Many Thanks
    Looking forward your response.

    Here is my C# code:
    Code:
    using System;using System.Collections.Generic;
    using System.Linq;
    
    
    using Autodesk.Revit.DB;
    using Autodesk.Revit.DB.Architecture;
    using Autodesk.Revit.UI;
    using Autodesk.Revit.UI.Selection;
    using Autodesk.Revit.ApplicationServices;
    using Autodesk.Revit.Attributes;
    using System.Text;
    using System.Windows.Forms;
    
    
    using JungHwanUI;
    
    
    
    
    
    
    [TransactionAttribute(TransactionMode.Manual)]
    [RegenerationAttribute(RegenerationOption.Manual)]
    public class JHUI : IExternalCommand
    {
        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            //Get application and document objects
            UIApplication uiApp = commandData.Application;
            Document doc = commandData.Application.ActiveUIDocument.Document;
    
    
            //Define a Reference object to accept the pick result.
            Reference pickedRef = null;
    
    
            //Pick a group
            Selection sel = uiApp.ActiveUIDocument.Selection;
            pickedRef = sel.PickObject(ObjectType.Element, "Please select a wall");
            Element elem = doc.GetElement(pickedRef);
    
    
            Wall wall = elem as Wall;
    
    
            double wallArea = wall.get_Parameter("Area").AsDouble();
    
    
            JHUIData data = new JHUIData();
    
    
            data.WallArea = wallArea;
    
    
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("Selected {0}\n", wall.Name);
            foreach (Material mat in wall.Materials)
            {
                double area = wall.GetMaterialArea(mat);
                double volume = wall.GetMaterialVolume(mat);
                double height = volume / area;
                double length = wall.get_Parameter("Length").AsDouble();
                double width = area / length;
                sb.AppendFormat("Material: {0}\nArea={1} ft^2\nVolume={2} ft^3\n" +
                    "Length={3} ft\nWidth={4} ft\nHeight={5} ft\nclass={6}", mat.Name,
                    area, volume, length, width, height, mat.MaterialClass);
    
    
                data.ElementName = wall.Name;
                JHUIData.CostLabMaterialInfo matInfo = new JHUIData.CostLabMaterialInfo();
                matInfo.MaterialName = mat.Name;
                matInfo.Area = area;
                matInfo.Volume = volume;
                matInfo.Length = length;
                matInfo.Width = width;
                matInfo.Height = height;
    
    
                data.AddMaterialInfo(matInfo);
            }
    
    
            string prompt = sb.ToString();
    
    
            TaskDialog taskDialog = new TaskDialog("JungHwangUI");
    
    
            // Nice to set stuffs
            taskDialog.Id = "ID_TaskDialog_JungHwanUI";
            taskDialog.MainIcon = TaskDialogIcon.TaskDialogIconNone;
            taskDialog.Title = "JHUI";
            taskDialog.TitleAutoPrefix = true;
            taskDialog.AllowCancellation = true;
    
    
            taskDialog.MainInstruction = "JHUI";
            taskDialog.MainContent = prompt;
    
    
            // Common button stuffs
            taskDialog.CommonButtons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Close;
    
    
            //TaskDialogResult result = taskDialog.Show();
    
    
            FormJHUI form = new FormJHUI(data);
    
    
            form.ShowDialog();
    
    
            //GetElementParameterInformation(doc, elem);
    
    
            //Pick a point
            //XYZ point = sel.PickPoint("Please pick a point to place group");
    
    
            //Place the group
            //Transaction trans = new Transaction(doc);
            //trans.Start("Lab");
            //doc.Create.PlaceGroup(point, group.GroupType);
            //trans.Commit();
    
    
            return Result.Succeeded;
        }
    }

  2. #2
    Member
    Join Date
    2012-09
    Posts
    34
    Login to Give a bone
    0

    Default Re: Problem with Revit's external command

    Expand the dialog box that appears telling you that you have an error message - you should see a more detailed explanation of what exactly has gone wrong.
    Currently there is not nearly enough information for anyone to determine what may be causing your problem.

Similar Threads

  1. Replies: 3
    Last Post: 2014-11-14, 08:39 AM
  2. cannot run external command
    By b.glendenning in forum Revit - API
    Replies: 1
    Last Post: 2009-12-14, 05:50 PM
  3. how do I run an external ARX command thru' VBA
    By pravin.pai in forum VBA/COM Interop
    Replies: 3
    Last Post: 2009-08-27, 03:30 PM
  4. No External Command
    By mschroeder in forum Revit - Student Support
    Replies: 0
    Last Post: 2008-12-05, 04:52 PM
  5. Replies: 6
    Last Post: 2008-11-20, 05:23 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •