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;
        }
Exemple #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("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;
        }
Exemple #3
0
        //----------------------------------------------------------
        public void Get_Location_Line(ComboBox location_line)
        {
            mySource = new ListSource();
            try
            {
                location_line_data = mySource.location_line_data;

                location_line.ItemsSource   = location_line_data;
                location_line.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #4
0
        //----------------------------------------------------------
        public ObservableCollection <parameter_data> View_Dimensions_FamilySymbol(Document doc, Element element, All_Data myAll_Data)
        {
            mySource = new ListSource();
            ObservableCollection <parameter_data> my_parameter_data = new ObservableCollection <parameter_data>();

            try
            {
                try
                {
                    foreach (Parameter para in element.Parameters)
                    {
                        try
                        {
                            if (para.Definition.ParameterGroup == BuiltInParameterGroup.PG_GEOMETRY && mySource.para_name_not_use.Contains(para.Definition.Name) == false && para.IsReadOnly == false)
                            {
                                string value = Get_Parameter_Information(para, doc, myAll_Data);
                                my_parameter_data.Add(new parameter_data()
                                {
                                    parameter_name  = para.Definition.Name,
                                    parameter_value = value,
                                    parameter       = para
                                });
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Bạn cần có ít nhất 1 đối tượng đã được vẽ để lấy thông tin!", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(my_parameter_data);
        }
Exemple #5
0
        //----------------------------------------------------------
        public string CreatePreview(ElementType type, All_Data myAll_Data)
        {
            string path = "";

            try
            {
                mySource = new ListSource();
                if (Directory.Exists(mySource.user + myAll_Data.list_path_foder_data[1]) == false)
                {
                    Directory.CreateDirectory(mySource.user + myAll_Data.list_path_foder_data[1]);
                }

                Size imgSize = new Size(200, 200);

                Bitmap image = type.GetPreviewImage(imgSize);

                // encode image to jpeg for test display purposes:

                JpegBitmapEncoder encoder
                    = new JpegBitmapEncoder();

                encoder.Frames.Add(BitmapFrame.Create(
                                       ConvertBitmapToBitmapSource(image)));

                encoder.QualityLevel = 25;

                path = mySource.user + myAll_Data.list_path_foder_data[1] + "\\" + type.FamilyName + ".jpg";

                FileStream file = new FileStream(path, FileMode.Create, FileAccess.Write);

                encoder.Save(file);
                file.Close();
            }
            catch (Exception ex)
            {
            }
            return(path);
        }
Exemple #6
0
        //----------------------------------------------------------
        public void Data_Pick_Element(UIDocument uidoc, Document doc,
                                      RadioButton center_mid_point, RadioButton line, RadioButton arc, RadioButton ellipse, RadioButton pick)
        {
            mySource = new ListSource();

            Selection selection = uidoc.Selection;

            if (center_mid_point.IsChecked == true && center_mid_point.IsEnabled == true)
            {
                List <XYZ> support = new List <XYZ>();
                support.Add(selection.PickPoint(ObjectSnapTypes.Endpoints | ObjectSnapTypes.Midpoints | ObjectSnapTypes.Centers | ObjectSnapTypes.Intersections | ObjectSnapTypes.Perpendicular | ObjectSnapTypes.Nearest | ObjectSnapTypes.Quadrants, "Select center point"));
                data_point = new geometry_data()
                {
                    name       = mySource.list_option_selection_name[0],
                    list_point = support
                };
            }
            if (line.IsChecked == true)
            {
                List <XYZ> support = new List <XYZ>();
                support.Add(selection.PickPoint(ObjectSnapTypes.Endpoints | ObjectSnapTypes.Midpoints | ObjectSnapTypes.Centers | ObjectSnapTypes.Intersections | ObjectSnapTypes.Perpendicular | ObjectSnapTypes.Nearest | ObjectSnapTypes.Quadrants, "Select start point"));
                support.Add(selection.PickPoint(ObjectSnapTypes.Endpoints | ObjectSnapTypes.Midpoints | ObjectSnapTypes.Centers | ObjectSnapTypes.Intersections | ObjectSnapTypes.Perpendicular | ObjectSnapTypes.Nearest | ObjectSnapTypes.Quadrants, "Select end point"));
                data_point = new geometry_data()
                {
                    name       = mySource.list_option_selection_name[1],
                    list_point = support
                };
            }
            if (arc.IsChecked == true && arc.IsEnabled == true)
            {
                List <XYZ> support = new List <XYZ>();
                support.Add(selection.PickPoint(ObjectSnapTypes.Endpoints | ObjectSnapTypes.Midpoints | ObjectSnapTypes.Centers | ObjectSnapTypes.Intersections | ObjectSnapTypes.Perpendicular | ObjectSnapTypes.Nearest | ObjectSnapTypes.Quadrants, "Select center point"));
                support.Add(selection.PickPoint(ObjectSnapTypes.Endpoints | ObjectSnapTypes.Midpoints | ObjectSnapTypes.Centers | ObjectSnapTypes.Intersections | ObjectSnapTypes.Perpendicular | ObjectSnapTypes.Nearest | ObjectSnapTypes.Quadrants, "Select start point"));
                support.Add(selection.PickPoint(ObjectSnapTypes.Endpoints | ObjectSnapTypes.Midpoints | ObjectSnapTypes.Centers | ObjectSnapTypes.Intersections | ObjectSnapTypes.Perpendicular | ObjectSnapTypes.Nearest | ObjectSnapTypes.Quadrants, "Select end point, not same start point"));
                data_point = new geometry_data()
                {
                    name       = mySource.list_option_selection_name[2],
                    list_point = support
                };
            }
            if (ellipse.IsChecked == true && ellipse.IsEnabled == true)
            {
                List <XYZ> support = new List <XYZ>();
                support.Add(selection.PickPoint(ObjectSnapTypes.Endpoints | ObjectSnapTypes.Midpoints | ObjectSnapTypes.Centers | ObjectSnapTypes.Intersections | ObjectSnapTypes.Perpendicular | ObjectSnapTypes.Nearest | ObjectSnapTypes.Quadrants, "Select start point define radius x"));
                support.Add(selection.PickPoint(ObjectSnapTypes.Endpoints | ObjectSnapTypes.Midpoints | ObjectSnapTypes.Centers | ObjectSnapTypes.Intersections | ObjectSnapTypes.Perpendicular | ObjectSnapTypes.Nearest | ObjectSnapTypes.Quadrants, "Select end point define radius x"));
                support.Add(selection.PickPoint(ObjectSnapTypes.Endpoints | ObjectSnapTypes.Midpoints | ObjectSnapTypes.Centers | ObjectSnapTypes.Intersections | ObjectSnapTypes.Perpendicular | ObjectSnapTypes.Nearest | ObjectSnapTypes.Quadrants, "Select start point define radius y"));
                support.Add(selection.PickPoint(ObjectSnapTypes.Endpoints | ObjectSnapTypes.Midpoints | ObjectSnapTypes.Centers | ObjectSnapTypes.Intersections | ObjectSnapTypes.Perpendicular | ObjectSnapTypes.Nearest | ObjectSnapTypes.Quadrants, "Select end point define radius y"));
                data_point = new geometry_data()
                {
                    name       = mySource.list_option_selection_name[3],
                    list_point = support
                };
            }
            if (pick.IsChecked == true)
            {
                var            refe     = selection.PickObject(ObjectType.PointOnElement, "Select reference of element");
                Element        element  = doc.GetElement(refe);
                GeometryObject geometry = element.GetGeometryObjectFromReference(refe);

                List <string> my_cad_link = new FilteredElementCollector(doc).OfClass(typeof(CADLinkType)).Cast <CADLinkType>().Select(x => x.Name).ToList();
                if (my_cad_link.Count() > 0 && my_cad_link.Contains(doc.GetElement(element.UniqueId).Category.Name))
                {
                    GeometryElement elem = element.get_Geometry(new Options());
                    if (elem != null)
                    {
                        foreach (GeometryObject geometryObject in elem)
                        {
                            GeometryInstance gInstance = geometryObject as GeometryInstance;
                            if (null != gInstance)
                            {
                                origin = gInstance.Transform.Origin;
                            }
                        }
                    }
                }

                if (geometry is Line)
                {
                    Line polyLine = geometry as Line;

                    data_point = new geometry_data()
                    {
                        name = mySource.list_option_selection_name[4],
                        line = polyLine
                    };
                }
                else if (geometry is PolyLine)
                {
                    PolyLine polyLine = geometry as PolyLine;
                    data_point = new geometry_data()
                    {
                        name     = mySource.list_option_selection_name[5],
                        polyLine = polyLine
                    };
                }
                else if (geometry is Arc)
                {
                    Arc polyLine = geometry as Arc;

                    data_point = new geometry_data()
                    {
                        name = mySource.list_option_selection_name[6],
                        arc  = polyLine
                    };
                }
                else if (geometry is Ellipse)
                {
                    Ellipse polyLine = geometry as Ellipse;

                    data_point = new geometry_data()
                    {
                        name    = mySource.list_option_selection_name[6],
                        ellipse = polyLine
                    };
                }
            }
        }