Esempio n. 1
0
        public void createLiningConcrete(UIDocument uiDoc)
        {
            // Set doc

            Document doc = uiDoc.Document;

            //Show Form
            SelectFamilyNameForms mySelFamilyForm = new SelectFamilyNameForms();

            mySelFamilyForm.offsetDisTb.Text = "100";


            FilteredElementCollector fec = new FilteredElementCollector(doc)
                                           .OfClass(typeof(FloorType))
                                           .OfCategory(BuiltInCategory.OST_Floors);


            IEnumerable <FloorType> iterFloorTypes = fec.Cast <FloorType>();

            // Lay danh sach vat lieu
            foreach (FloorType myItemType in iterFloorTypes)
            {
                mySelFamilyForm.FamilysCb.Items.Add(myItemType.Name.ToString());
            }


            double offsetVal = Convert.ToDouble(valueOfSetting(@"C:\Revit Setting\RevitSetting.set", "LiningConcreteOffset")) / 304.8;

            int indexSel = mySelFamilyForm.FamilysCb.Items.IndexOf(valueOfSetting(@"C:\Revit Setting\RevitSetting.set", "LiningConcreteFamily"));

            mySelFamilyForm.FamilysCb.SelectedIndex = indexSel;
            mySelFamilyForm.ShowDialog();

            string nameSelectedFamily = mySelFamilyForm.FamilysCb.SelectedItem.ToString();


            //filter element
            List <int> myListCatoId = new List <int>();

            myListCatoId.Add((int)BuiltInCategory.OST_StructuralFoundation);
            myListCatoId.Add((int)BuiltInCategory.OST_StructuralFraming);

            List <Reference> myListRef = uiDoc.Selection.PickObjects(ObjectType.Element, new FilterByIdCategory(myListCatoId), "Select Beam or Slab") as List <Reference>;

            if (myListRef.Count() < 1)
            {
                return;
            }


            foreach (Reference myRef in myListRef)
            {
                //Get ElementId from ref
                ElementId myFoundationId = doc.GetElement(myRef).Id;

                createLiningConcreteAsFloor2(doc, myFoundationId, nameSelectedFamily, offsetVal);
            }

            mySelFamilyForm.Close();
        }
Esempio n. 2
0
        public void createLiningConcrete(UIDocument uiDoc)
        {
            // Set doc
            Document doc = uiDoc.Document;

            //Show Form

            SelectFamilyNameForms mySelFamilyForm = new SelectFamilyNameForms();



            FilteredElementCollector fec = new FilteredElementCollector(doc)
                                           .OfClass(typeof(FloorType))
                                           .OfCategory(BuiltInCategory.OST_Floors);


            IEnumerable <FloorType> iterFloorTypes = fec.Cast <FloorType>();

            // Lay danh sach vat lieu
            foreach (FloorType myItemType in iterFloorTypes)
            {
                mySelFamilyForm.FamilysCb.Items.Add(myItemType.Name.ToString());

                //mySelMatForm.listMatCb.Items.Add(myItemType.Name.ToString());
            }
            double offsetVal = 100;

            try
            {
                offsetVal = Convert.ToDouble(valueOfSetting(@"D:\Revit Setting\RevitSetting.set", "LiningConcreteOffset"));
            }

            catch
            {
                mySelFamilyForm.offsetDisTb.Text = "100";
            }

            mySelFamilyForm.offsetDisTb.Text = offsetVal.ToString();


            int indexSel = mySelFamilyForm.FamilysCb.Items.IndexOf(valueOfSetting(@"D:\Revit Setting\RevitSetting.set", "LiningConcreteFamily"));

            mySelFamilyForm.FamilysCb.SelectedIndex = indexSel;
            mySelFamilyForm.ShowDialog();

            string nameSelectedFamily = mySelFamilyForm.FamilysCb.SelectedItem.ToString();

            offsetVal = Convert.ToDouble(mySelFamilyForm.offsetDisTb.Text);

            // Get the element selection of current document.
            Selection selection = uiDoc.Selection;
            ICollection <ElementId> selectedIds = uiDoc.Selection.GetElementIds();

            if (selectedIds.Count < 1)
            {
                //filter element
                List <int> myListCatoId = new List <int>();
                myListCatoId.Add((int)BuiltInCategory.OST_StructuralFoundation);
                myListCatoId.Add((int)BuiltInCategory.OST_StructuralFraming);

                List <Reference> myListRef = uiDoc.Selection.PickObjects(ObjectType.Element, new FilterByIdCategory(myListCatoId), "Select Beam or Slab") as List <Reference>;

                if (myListRef.Count() < 1)
                {
                    return;
                }
                else
                {
                    foreach (Reference myRef in myListRef)
                    {
                        selectedIds.Add(doc.GetElement(myRef).Id);
                    }
                }
            }

            bool isLiningBottomBeam = false;

            foreach (ElementId myFoundationId in selectedIds)
            {
                //				//Get ElementId from ref
                //				ElementId myFoundationId = doc.GetElement(myRef).Id;
                Element myCurrentFoundationAs = doc.GetElement(myFoundationId);

                if (myCurrentFoundationAs.Category.Name == "Structural Framing")
                {
                    isLiningBottomBeam = true;
                }

                else
                {
                    isLiningBottomBeam = false;
                }

                List <List <Floor> > myListListFloor = createLiningConcreteAsFloor2(doc, myFoundationId,
                                                                                    nameSelectedFamily,
                                                                                    offsetVal / 304.8, isLiningBottomBeam);

                foreach (Floor myFloorLining in myListListFloor[0])
                {
                    switchJoinOrder(doc, myFloorLining);
                }

                foreach (Floor myFloorLiningCutting in myListListFloor[1])
                {
                    joiningLining(doc, myFloorLiningCutting);
                }
            }

            mySelFamilyForm.Close();
        }