Esempio n. 1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiApp = commandData.Application;



            UIDocument doc = uiApp.ActiveUIDocument;
            //commandData.View.
            IWin32Window revit_window = new JtWindowHandle(ComponentManager.ApplicationWindow);


            Selection selection = doc.Selection;


            ICollection <ElementId> selectedIds = selection.GetElementIds();
            Element SelectedElement = null, FamilleElement = null;

            if (0 == selectedIds.Count)
            {
                // If no elements selected.
                Autodesk.Revit.UI.TaskDialog.Show("Revit", "You haven't selected any elements.");
                return(Result.Succeeded);
            }
            else if (1 == selectedIds.Count)
            {
                foreach (ElementId id in selectedIds)
                {
                    SelectedElement = doc.Document.GetElement(id);
                    FamilleElement  = doc.Document.GetElement(SelectedElement.GetTypeId());
                }

                //TaskDialog.Show("Revit", info);
            }
            else if (1 < selectedIds.Count)
            {
                // If no elements selected.
                Autodesk.Revit.UI.TaskDialog.Show("Revit", "You have selected more than 1 elements.");
                return(Result.Succeeded);
            }

            if (SelectedElement != null)
            {
                API.LightFixture fix = API.LightManager.GetLight(SelectedElement.UniqueId);

                ConfigurationForm frm = new ConfigurationForm();
                frm.LoadTree();
                frm.Fixture = fix;
                frm.ShowDialog(revit_window);
            }
            return(Result.Succeeded);
        }
Esempio n. 2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiApp = commandData.Application;


            UIDocument doc = uiApp.ActiveUIDocument;


            Selection selection = doc.Selection;


            ICollection <ElementId> selectedIds = selection.GetElementIds();
            Element SelectedElement = null, FamilleElement = null;

            if (0 == selectedIds.Count)
            {
                // If no elements selected.
                Autodesk.Revit.UI.TaskDialog.Show("Revit", "You haven't selected any elements.");
                return(Result.Succeeded);
            }
            else if (1 == selectedIds.Count)
            {
                foreach (ElementId id in selectedIds)
                {
                    SelectedElement = doc.Document.GetElement(id);
                    FamilleElement  = doc.Document.GetElement(SelectedElement.GetTypeId());
                }

                //TaskDialog.Show("Revit", info);
            }
            else if (1 < selectedIds.Count)
            {
                // If no elements selected.
                Autodesk.Revit.UI.TaskDialog.Show("Revit", "You have selected more than 1 elements.");
                return(Result.Succeeded);
            }

            if (SelectedElement != null)
            {
                API.LightFixture fix = API.LightManager.GetLight(SelectedElement.UniqueId);
                if (fix.AreaId == API.LightFixture.UNKNOW_LIGHT_ID)
                {
                    Autodesk.Revit.UI.TaskDialog.Show("Revit", "Fixture not configured");
                    return(Result.Succeeded);
                }

                fix.Off();
            }
            return(Result.Succeeded);
        }
Esempio n. 3
0
        static public void SaveXml()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<XmlLightMngt></XmlLightMngt>");

            foreach (var item in _Lights)
            {
                LightFixture fix = item.Value;

                XmlElement ele = doc.CreateElement("Light");
                ele.SetAttribute("GUID", fix.GUID);
                ele.SetAttribute("AreaId", fix.AreaId.ToString());
                ele.SetAttribute("LuminaireId", fix.LuminaireId.ToString());
                if (fix.LuminaireId == LightFixture.UNKNOW_LIGHT_ID)
                {
                    ele.SetAttribute("OnLevelForArea", fix.LuminaireId.ToString());
                    ele.SetAttribute("OffLevelForArea", fix.LuminaireId.ToString());
                }
                doc.DocumentElement.AppendChild(ele);
            }
            doc.Save(XmlFileName);
        }
Esempio n. 4
0
        public static LightFixture GetLight(string GUID)
        {
            if (_Lights == null)
            {
                _Lights = new Dictionary <string, LightFixture>();

                LoadXml();
            }

            LightFixture light = new LightFixture(GUID);

            if (_Lights.TryGetValue(GUID, out light))
            {
                return(light);
            }
            else
            {
                light = new LightFixture(GUID);
                _Lights.Add(GUID, light);
            }

            return(light);
        }