Пример #1
0
        public UserControl1(UIApplication _uiapp)
        {
            InitializeComponent();
            uiapp = _uiapp;
            uidoc = uiapp.ActiveUIDocument;
            doc   = uidoc.Document;

            myExternal_Draw         = new External_Draw();
            Draw                    = ExternalEvent.Create(myExternal_Draw);
            myExternal_Crop         = new External_Crop();
            Crop                    = ExternalEvent.Create(myExternal_Crop);
            myExternal_Sort_Section = new External_Sort_Section();
            Sort                    = ExternalEvent.Create(myExternal_Sort_Section);

            mySupport_All  = new Support_All();
            mySupport_Draw = new Support_Draw();
            Data_for_Support_Draw();
            mySupport_Crop = new Support_Crop();
            Data_for_Support_Crop();

            mySQL    = new FunctionSQL();
            mySource = new ListSource();

            var listtotal = mySQL.SQLRead(@"Server=18.141.116.111,1433\SQLEXPRESS;Database=ManageDataBase;User Id=ManageUser; Password = manage@connect789", "Select * from dbo.PathSource", "Query", new List <string>(), new List <string>());

            path = listtotal.Rows[0][1].ToString();
            Function_TXT();
            Function_Dau_Vao();
        }
Пример #2
0
        public void Execute(UIApplication uiapp)
        {
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            mySource          = new ListSource();
            myFunctionSupport = new Support_All();

            try
            {
                Transaction transaction = new Transaction(doc);
                transaction.Start("Crop");

                if (command == "Crop View")
                {
                    Apply_Crop(uiapp, doc);
                }

                transaction.Commit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return;
        }
Пример #3
0
        public void Execute(UIApplication uiapp)
        {
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            mySource          = new ListSource();
            myFunctionSupport = new Support_All();

            try
            {
                Transaction transaction = new Transaction(doc);
                transaction.Start("Draw");

                if (command == "Update Data Tag")
                {
                    string result = Update_Data_Tag(uiapp, doc);
                }

                if (command == "Update By Revit")
                {
                    Update_By_Revit(uiapp, doc);
                }

                if (command == "Draw By Revit")
                {
                    if (data_point != null)
                    {
                        string result = Draw_By_Revit(uiapp, doc);
                        if (result == "S")
                        {
                            data_point = null;
                        }
                    }
                }

                if (command == "Draw By CAD")
                {
                    Draw_By_CAD(uiapp, doc);
                }

                if (command == "Duplicate Type")
                {
                    Duplicate_Type(uiapp, doc);
                }

                transaction.Commit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return;
        }
Пример #4
0
        //----------------------------------------------------------
        public void Apply_Sort(UIApplication uiapp, Document doc)
        {
            try
            {
                myFunctionSupport = new Support_All();
                parameter_data     item1             = (parameter_data)parameter_1.SelectedItem;
                parameter_data     item2             = (parameter_data)parameter_2.SelectedItem;
                parameter_data     item3             = (parameter_data)parameter_3.SelectedItem;
                List <ViewSection> list_view_section = new List <ViewSection>();

                var list_viewsection = new FilteredElementCollector(doc).OfClass(typeof(ViewSection)).Cast <ViewSection>().ToList();
                foreach (var view in list_viewsection)
                {
                    if (myFunctionSupport.Get_Parameter_Information(view.LookupParameter(item1.parameter_name), doc, myAll_Data) == value_1.Text &&
                        myFunctionSupport.Get_Parameter_Information(view.LookupParameter(item2.parameter_name), doc, myAll_Data) == value_2.Text &&
                        myFunctionSupport.Get_Parameter_Information(view.LookupParameter(item3.parameter_name), doc, myAll_Data) == value_3.Text)
                    {
                        list_view_section.Add(view);
                    }
                }

                List <view_section_list_data> list_view_section_data = new List <view_section_list_data>();
                for (int i = Convert.ToInt32(sheet_start.Text); i < Convert.ToInt32(sheet_end.Text) + 1; i++)
                {
                    foreach (ViewSection view in list_view_section)
                    {
                        if (myFunctionSupport.Get_Parameter_Information(view.LookupParameter("Sheet Number"), doc, myAll_Data) == i.ToString())
                        {
                            list_view_section_data.Add(new view_section_list_data()
                            {
                                view_section = view,
                                sheet_number = i.ToString()
                            });
                        }
                    }
                }

                Change_Number(uiapp, doc, list_view_section_data);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #5
0
        //----------------------------------------------------------
        public void Get_Family(Document doc, ComboBox category, ComboBox family, All_Data myAll_Data)
        {
            mySupport_All = new Support_All();
            try
            {
                category_data item = (category_data)category.SelectedItem;

                ElementMulticategoryFilter filter_category = new ElementMulticategoryFilter(new List <BuiltInCategory>()
                {
                    item.builtin
                });
                my_family_data = new ObservableCollection <family_data>(new FilteredElementCollector(doc)
                                                                        .WherePasses(filter_category)
                                                                        .WhereElementIsElementType()
                                                                        .Cast <ElementType>()
                                                                        .GroupBy(x => new
                {
                    x.FamilyName,
                })
                                                                        .ToList().Select(x => new family_data()
                {
                    single_value = x.Key.FamilyName,
                    path_image   = mySupport_All.CreatePreview(x.First(), myAll_Data),
                    types        = x.Select(y => y).ToList()
                }).OrderBy(x => x.single_value));

                family.ItemsSource   = my_family_data;
                family.SelectedIndex = 0;

                CollectionView view_family = (CollectionView)CollectionViewSource.GetDefaultView(family.ItemsSource);
                view_family.SortDescriptions.Add(new SortDescription("single_value", ListSortDirection.Ascending));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #6
0
        //----------------------------------------------------------
        public void Get_Parameter(Element element_update, Document doc,
                                  ComboBox category, ComboBox family, ComboBox type, ListView thong_tin_parameter,
                                  All_Data myAll_Data)
        {
            mySupport_All = new Support_All();
            try
            {
                category_data item_cate = (category_data)category.SelectedItem;
                family_data   item      = (family_data)family.SelectedItem;
                type_data     item_type = (type_data)type.SelectedItem;

                ElementMulticategoryFilter filter_category = new ElementMulticategoryFilter(new List <BuiltInCategory>()
                {
                    item_cate.builtin
                });
                if (item != null && item.single_value != "" && new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(x => x.Name == item_type.type.Name).ToList().Count() > 0)
                {
                    var list_element = new FilteredElementCollector(doc)
                                       .WherePasses(filter_category)
                                       .WhereElementIsNotElementType()
                                       .Where(x => (x as FamilyInstance).Symbol.FamilyName == item.single_value)
                                       .Where(x => x.Name == item_type.single_value)
                                       .ToList();

                    if (element_update != null)
                    {
                        my_parameter_data = new ObservableCollection <parameter_data>(mySupport_All.View_Dimensions_FamilySymbol(doc, element_update, myAll_Data));
                    }
                    else if (list_element.Count() > 0)
                    {
                        my_parameter_data = new ObservableCollection <parameter_data>(mySupport_All.View_Dimensions_FamilySymbol(doc, list_element[0], myAll_Data));
                    }
                    else
                    {
                        Family fa = new FilteredElementCollector(doc).OfClass(typeof(Family)).Cast <Family>().Where(x => x.Name == item.single_value).First();
                        my_parameter_data = new ObservableCollection <parameter_data>();
                        if (fa.IsEditable)
                        {
                            Document      familyDoc = doc.EditFamily(fa);
                            FamilyManager manager   = familyDoc.FamilyManager;

                            foreach (FamilyParameter para in manager.Parameters)
                            {
                                try
                                {
                                    if (para.IsInstance && para.Definition.ParameterGroup == BuiltInParameterGroup.PG_GEOMETRY && mySource.para_name_not_use.Contains(para.Definition.Name) == false && para.IsReadOnly == false)
                                    {
                                        my_parameter_data.Add(new parameter_data()
                                        {
                                            parameter_name  = para.Definition.Name,
                                            parameter_value = mySupport_All.Get_Parameter_Information_Family(para, familyDoc, manager, myAll_Data),
                                            parameter       = null
                                        });
                                    }
                                }
                                catch (Exception)
                                {
                                }
                            }
                            familyDoc.Close(false);
                        }
                    }

                    thong_tin_parameter.ItemsSource = my_parameter_data;
                }
                else
                {
                    thong_tin_parameter.ItemsSource = new ObservableCollection <parameter_data>();
                }

                CollectionView view_para = (CollectionView)CollectionViewSource.GetDefaultView(thong_tin_parameter.ItemsSource);
                view_para.SortDescriptions.Add(new SortDescription("parameter_name", ListSortDirection.Ascending));
            }
            catch (Exception ex)
            {
                ////MessageBox.Show(ex.Message);
            }
        }