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

            Element e = null;

            while (true)
            {
                try
                {
                    e = Util.SelectSingleElementOfType(
                        uidoc, typeof(Element), "an element", true);
                }
                catch (Autodesk.Revit.Exceptions.OperationCanceledException)
                {
                    message = "No element selected";
                    break;
                }
                if (null == e)
                {
                    break;
                }

                Util.InfoMsg(string.Format(
                                 //"{0} is {1} {2} ({3})",
                                 "{0} is {1} ({2})",
                                 Util.ElementDescription(e),
                                 //MepElementShapeVersion3.GetElementShape( e ),
                                 MepElementShapeVersion2.GetElementShape(e),
                                 MepElementShapeV1.GetElementShape(e)));
            }
            return(Result.Succeeded);
        }
Beispiel #2
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            int n = uidoc.Selection.GetElementIds().Count;

            bool preselected = 0 < n;

            Element e = null;

            while (true)
            {
                try
                {
                    e = Util.SelectSingleElementOfType(
                        uidoc, typeof(Element), "an element", true);
                }
                catch (Autodesk.Revit.Exceptions.OperationCanceledException)
                {
                    message = "No element selected";
                    break;
                }
                if (null == e)
                {
                    break;
                }

                string s = "Not a duct.";

                Duct duct = e as Duct;

                if (null != duct)
                {
                    ConnectorProfileType[] profileTypes
                        = GetProfileTypes(duct);

                    n = profileTypes.GetLength(0);

                    s = string.Format("{0} connectors:\r\n", n)
                        + string.Join("\r\n", profileTypes
                                      .Select <ConnectorProfileType, string>(
                                          a => a.ToString()));
                }

                string msg = string.Format(
                    //"{0} is {1} {2} ({3})",
                    "{0} is {1}-{2} ({3})",
                    Util.ElementDescription(e),
                    //MepElementShapeVersion3.GetElementShape( e ),
                    GetElementShape4(e),
                    MepElementShapeVersion2.GetElementShape(e),
                    MepElementShapeV1.GetElementShape(e));

                Util.InfoMsg2(msg, s);

                if (preselected)
                {
                    break;
                }
            }
            return(Result.Succeeded);
        }