Esempio n. 1
0
        public void Main_Create(Document revitDoc, UIDocument uidoc)
        {
            /// 建立CAD處理物件
            GetCADImformation GetCADImformation = new GetCADImformation(true, true, true);

            GetCADImformation.CADProcessing(uidoc);

            Dictionary <string, List <LINE> > CADGeometry = GetCADImformation.LayersAndGeometries;

            if (CADGeometry == null)
            {
                return;
            }


            /// 取得Revit指定的FamilyTypes
            Dictionary <string, List <Dictionary <string, List <FamilySymbol> > > > LightFamilyTypes = CatchLightFamilyType(RevFind.GetDocLightTypes(revitDoc));
            /// 取得Revit所有樓層資訊
            List <Level> levels = RevFind.GetLevels(revitDoc);
            /// 建立Form物件
            Form_CreateLight Form = new Form_CreateLight(LightFamilyTypes, levels, CADGeometry);

            Form.ShowDialog();

            /// 確認是要用圓形或者是多邊形心中來建立物件
            string RadioCase = Form.radCircle.Checked == true ? "Circle" : (Form.radPloyline.Checked == true ? "Ployline" : "Square");

            if (Form.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                /// 樓層偏移量
                double SHIFT = Convert.ToDouble(Form.txtShift.Text) / 304.8;
                /// 取得目標樓層的所有幾何資訊
                List <LINE> LINES_ = CADGeometry[Form.cmbColCADLayers.Text];
                /// 針對圓形或多邊形處理幾何資訊
                List <LINE> LINES = GetPolylineAndLineClosedRegion(LINES_, RadioCase);
                /// 將重複的點拿掉
                List <XYZ> centerPoint = TakeOffSameLightPoint(LINES);

                /// 激活FamilyType
                StartFamilyType(Form.returnType[0], revitDoc);

                /// 開始建立物件
                CreateLight(Form.returnType[0], Form.returnBaseLevel[0], revitDoc, centerPoint, SHIFT);
            }

            Form.Dispose();
        }
Esempio n. 2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////// CAD Part /////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public void Main_Create(Document revitDoc, UIDocument uidoc)
        {
            /// 建立CAD處理物件
            GetCADImformation GetCADImformation = new GetCADImformation(false, false, false);

            GetCADImformation.CADProcessing(uidoc);

            /// 取得CAD Hash區域
            Dictionary <string, List <List <LINE> > > FloorRegions = GetCADImformation.LayersAndClosedRegions;

            /// 若沒選擇CAD 則回傳
            if (FloorRegions.Count == 0)
            {
                return;
            }

            /// 取得所有樓層
            List <Level> levels = RevFind.GetLevels(revitDoc);
            /// 取得所有板的種類
            List <Element> floorTypes = RevFind.GetDocFloorTypes(revitDoc);
            /// 建立GUI建面並呼叫
            Form_CreateFloorByCADHash Form = new Form_CreateFloorByCADHash(FloorRegions.Keys.ToList(), levels, floorTypes);

            Form.ShowDialog();


            if (Form.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                double    SHIFT        = Convert.ToDouble(Form.txtShift.Text) / 304.8;
                string    Layers       = Form.cmbCADLayers.SelectedItem.ToString();
                bool      IsStructural = Form.chIsStructural.Checked ? true : false;
                Level     level        = levels[Form.cmbBaseLevels.SelectedIndex];
                FloorType floorType    = floorTypes[Form.cmbFloorTypes.SelectedIndex] as FloorType;

                bool IndicatiedLayers      = Form.chIsIndicatedLayers.Checked;
                List <List <LINE> > Region = RegionProcess(IndicatiedLayers, Layers, FloorRegions);
                CreateFloor(revitDoc, level, Region, floorType, SHIFT, IsStructural);
            }
        }
Esempio n. 3
0
        public void Main_Create(Document revitDoc, UIDocument uidoc)
        {
            /// 建立CAD處理物件
            GetCADImformation GetCADImformation = new GetCADImformation(true, true, true);

            GetCADImformation.CADProcessing(uidoc);

            /// 讀取Revit匯入之CAD圖層
            Dictionary <string, List <LINE> > CADGeometry = GetCADImformation.LayersAndGeometries;

            //if (CADGeometry == null) return;
            //LINE SHIFT2 = CADGeometry[ModifyLayerName][0];

            XYZ    SHIFT    = GetCADImformation.Origin;
            double Rotation = GetCADImformation.Rotation;

            /// 擷取Revit所有樓層資訊
            List <Level> levels = RevFind.GetLevels(revitDoc);

            /// 呼叫Form介面來選擇指定的CAD_output檔案
            Form_InsertCommentToBeam FIC = new Form_InsertCommentToBeam(levels);

            FIC.ShowDialog();

            if (FIC.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                List <CADGeoObject> DATA_CAD_TEXT = new List <CADGeoObject>();
                List <CADGeoObject> DATA_CAD_GEOM = new List <CADGeoObject>();
                LoadCADOutCSVData(FIC.txtFilePath.Text, ref DATA_CAD_GEOM, ref DATA_CAD_TEXT);


                Form_InsertShowLayers FIC_Layer = new Form_InsertShowLayers(DATA_CAD_TEXT);
                FIC_Layer.ShowDialog();
                if (FIC_Layer.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    List <CADGeoObject> TEXT_DATA = FIC_Layer.Selected_DATA;
                    /// Revit-CAD 與 CAD 座標偏移計算
                    List <CADGeoObject> RESULT    = ShiftProcessing(TEXT_DATA, SHIFT, Rotation);
                    List <CADGeoObject> GeoRESULT = ShiftProcessing(DATA_CAD_GEOM, SHIFT, Rotation);

                    /// 取得所選取之樓層
                    string Message = "";
                    foreach (Level targetLevel in FIC.OUT_SelectedLevels)
                    {
                        string mess = "";
                        if (FIC.cmbFamilyType.SelectedIndex == 0)
                        {
                            /// 取得Revit中所選樓層之所有梁物件
                            List <Element> Ele_BEAMS_OUT  = new List <Element>();
                            List <Element> Ele_BEAMS_OUT_ = new List <Element>();
                            List <LINE>    BEAMS_         = GetTargetFloorBeams(revitDoc, targetLevel, ref Ele_BEAMS_OUT_);
                            List <LINE>    BEAMS          = FilterObjectInRange(BEAMS_, GeoRESULT, Ele_BEAMS_OUT_, ref Ele_BEAMS_OUT);
                            mess = InsertCommentToBeams(revitDoc, BEAMS, Ele_BEAMS_OUT, RESULT, FIC.cmbFamilyType.SelectedIndex);
                        }
                        else if (FIC.cmbFamilyType.SelectedIndex == 1)
                        {
                            List <Element> Ele_COLUMNs_OUT_ = new List <Element>();
                            List <Element> Ele_COLUMNs_OUT  = new List <Element>();
                            List <LINE>    Columns_         = GetAllColumnsCenterByLocation(revitDoc, targetLevel, ref Ele_COLUMNs_OUT_);
                            List <LINE>    Columns          = FilterObjectInRange(Columns_, GeoRESULT, Ele_COLUMNs_OUT_, ref Ele_COLUMNs_OUT);
                            mess = InsertCommentToBeams(revitDoc, Columns, Ele_COLUMNs_OUT, RESULT, FIC.cmbFamilyType.SelectedIndex);
                        }
                        Message += "第" + targetLevel.Name + "層," + mess;
                    }

                    System.Windows.Forms.MessageBox.Show(Message);
                }
            }
        }