public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;

            uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;

            doc = uidoc.Document;
            sel = uidoc.Selection;
            var listgrid = Getmodelelement.GetAllGridinView(doc.ActiveView, doc);

            using (var form = new FrmMathGridView(doc))
            {
                if (form.ShowDialog() != true)
                {
                    using (Transaction tran = new Transaction(doc, "Math Grid"))
                    {
                        tran.Start();
                        foreach (var item in form.listview)
                        {
                            Doing(listgrid, doc.ActiveView, item);
                        }
                        tran.Commit();
                    }
                }
            }
            return(Result.Succeeded);
        }
Beispiel #2
0
        public void Create3dGrid(Document doc, FamilySymbol symbol)
        {
            var alllevel  = Getmodelelement.GetallFloorplan(doc);
            var listgrids = Getmodelelement.GetAllGrid(doc);

            foreach (var item in listgrids)
            {
                Line   line     = item.Curve as Line;
                string namegrid = item.Name;
                var    instance = doc.Create.NewFamilyInstance(item.Curve, symbol, alllevel.First().GenLevel, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
                var    text     = instance.LookupParameter("Text");
                text.SetParameterValue(namegrid);
                instance.Pinned = true;
            }
            ParameterFilterElement parameterFilterElement;

            CreateFilterRule3dGrid(doc, out parameterFilterElement);
            AddFilterRule(doc, parameterFilterElement);
        }
Beispiel #3
0
        public void AddFilterRule(Document doc, ParameterFilterElement parameterFilterElement)
        {
            List <View> ListViewTemplate = Getmodelelement.GetallViewTeamplate(doc);

            foreach (View item in ListViewTemplate)
            {
                if (CheckFilterinview(doc, item))
                {
                    continue;
                }
                else
                {
                    item.AddFilter(parameterFilterElement.Id);
                    if (doc.ActiveView.ViewTemplateId == item.ViewTemplateId)
                    {
                        item.SetFilterVisibility(parameterFilterElement.Id, true);
                    }
                    else
                    {
                        item.SetFilterVisibility(parameterFilterElement.Id, false);
                    }
                }
            }
        }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;

            uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;

            doc           = uidoc.Document;
            sel           = uidoc.Selection;
            Setting       = SettingTopDT.Instance.GetSetting();
            listTextnotes = Getmodelelement.GetTextNoteTypes(doc);
            using (var form = new FrmTopDT(this))
            {
                if (form.ShowDialog() != true && form.check)
                {
                    while (iscontinue)
                    {
                        Transaction tran = new Transaction(doc, "Callout dimension");
                        tran.Start();
                        try
                        {
                            Reference reference = sel.PickObject(ObjectType.Element, new FilterSpotElevation(), "Select Spot Elevation");
                            var       element   = doc.GetElement(reference);
                            var       top       = element.LookupParameter("Single/Upper Value").AsValueString();
                            string    val1      = string.Empty;
                            string    n         = string.Empty;
                            double    val2      = double.MinValue;
                            if (!string.IsNullOrEmpty(form.val) && form.tru == "")
                            {
                                val2 = UnitConvert.StringToFeetAndInches(top, out val1) + UnitConvert.StringToFeetAndInches(form.val, out n);
                            }
                            if (!string.IsNullOrEmpty(form.tru) && form.val == "")
                            {
                                val2 = UnitConvert.StringToFeetAndInches(top, out val1) - UnitConvert.StringToFeetAndInches(form.tru, out n);
                            }
                            var    val3  = UnitConvert.DoubleToImperial(val2);
                            string empty = UnitConvert.StringToFeetAndInchesformattext(val3);
                            if (!string.IsNullOrEmpty(form.Suffix) && string.IsNullOrEmpty(form.Prefix))
                            {
                                CreteaTextnode(doc, empty + " " + form.Suffix, form.TextNoteType);
                            }
                            if (string.IsNullOrEmpty(form.Suffix) && !string.IsNullOrEmpty(form.Prefix))
                            {
                                CreteaTextnode(doc, form.Prefix + " " + empty, form.TextNoteType);
                            }
                            if (!string.IsNullOrEmpty(form.Suffix) && !string.IsNullOrEmpty(form.Prefix))
                            {
                                CreteaTextnode(doc, form.Prefix + " " + empty + " " + form.Suffix, form.TextNoteType);
                            }
                        }
                        catch (Exception)
                        {
                            this.iscontinue = false;
                        }
                        tran.Commit();
                    }
                }
            }
            return(Result.Succeeded);
        }
Beispiel #5
0
 public void Loaddata()
 {
     Source = Getmodelelement.GetAllViews(_doc);
     Listboxview(Source);
 }
        public Dictionary <string, Partinfo> GetPartDictionary(Document doc)
        {
            var legends = Getmodelelement.Getlegends(doc);
            Dictionary <string, Partinfo> dictionary = new Dictionary <string, Partinfo>();
            FilteredElementCollector      filteredElementCollector = new FilteredElementCollector(doc);
            IList <Element> list = filteredElementCollector.OfClass(typeof(FamilyInstance)).ToElements();

            foreach (Element item in list)
            {
                FamilyInstance familyInstance  = item as FamilyInstance;
                FamilyInstance familyInstance2 = familyInstance?.SuperComponent as FamilyInstance;
                if (familyInstance2 != null && familyInstance2.SuperComponent == null)
                {
                    Autodesk.Revit.DB.Parameter parameter = familyInstance.Symbol.LookupParameter("CONTROL_MARK");
                    if (parameter != null && parameter.StorageType == StorageType.String)
                    {
                        string text = parameter.AsString();
                        if (!string.IsNullOrEmpty(text))
                        {
                            string name  = familyInstance2.Symbol.Name;
                            string text2 = familyInstance.LookupParameter("BOM_PRODUCT_HOST")?.AsString() ?? "";
                            if (dictionary.ContainsKey(text))
                            {
                                if (string.IsNullOrEmpty(dictionary[text].ProductName))
                                {
                                    dictionary[text].ProductName = text2;
                                }
                                else if (!dictionary[text].ProductName.Contains(text2))
                                {
                                    dictionary[text].ProductName = dictionary[text].ProductName + "; " + text2;
                                }
                                if (dictionary[text].Connection == null)
                                {
                                    dictionary[text].Connection = name;
                                }
                                else if (!dictionary[text].Connection.Contains(name))
                                {
                                    dictionary[text].Connection = dictionary[text].Connection + "; " + name;
                                }
                                bool flag = (from x in legends where x.Name.Equals(text) select x).ToList().Count != 0;
                                if (flag)
                                {
                                    dictionary[text].Draw = "true";
                                }
                                else
                                {
                                    dictionary[text].Draw = "false";
                                }
                            }
                            else
                            {
                                dictionary[text] = new Partinfo
                                {
                                    ProductName = text2
                                };
                                string description = familyInstance.Symbol.LookupParameter("IDENTITY_DESCRIPTION")?.AsString();
                                dictionary[text].Description = description;
                                dictionary[text].Connection  = name;
                                bool flag = (from x in legends where x.Name.Equals(text) select x).ToList().Count != 0;
                                if (flag)
                                {
                                    dictionary[text].Draw = "true";
                                }
                                else
                                {
                                    dictionary[text].Draw = "false";
                                }
                            }
                        }
                    }
                }
            }
            return(dictionary);
        }