public FamilyInstanceWithApparentLoadSelectionFilter(
     ElectricalApparentLoadFactory
     electricalApparentLoadFactory)
 {
     this.electricalApparentLoadFactory
         = electricalApparentLoadFactory;
 }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            var app   = commandData.Application;
            var uidoc = app.ActiveUIDocument;

            var familyInstance
                = SelectFamilyInstanceWithApparentLoad(
                      uidoc);

            if (familyInstance == null)
            {
                return(Result.Cancelled);
            }

            var electricalApparentLoadFactory
                = new ElectricalApparentLoadFactory();

            var apparentLoads = electricalApparentLoadFactory
                                .Create(familyInstance);

            TaskDialog.Show("CmdElectricalLoad",
                            string.Join("\n", apparentLoads));

            return(Result.Succeeded);
        }
Beispiel #3
0
        private static FamilyInstance SelectFamilyInstanceWithApparentLoad(UIDocument uidoc)
        {
            var electricalApparentLoadFactory = new ElectricalApparentLoadFactory();

            var selectionFilter = new FamilyInstanceWithApparentLoadSelectionFilter(electricalApparentLoadFactory);

            try
            {
                return((FamilyInstance)uidoc.Document.GetElement(uidoc.Selection.PickObject(ObjectType.Element, selectionFilter)));
            }
            catch (OperationCanceledException)
            {
                return(null);
            }
        }