Exemple #1
0
        /// <summary>
        /// prepare data for the dialog
        /// </summary>
        public void PrepareData()
        {
            //Create seven Load Natures first
            CreateLoadNatures();

            //get all the categories of load cases
            UIApplication uiapplication = new UIApplication(m_revit);

            //get all the loadnatures name
            IList <Element> elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadNature)).ToElements();

            foreach (Element e in elements)
            {
                LoadNature nature = e as LoadNature;
                if (null != nature)
                {
                    m_dataBuffer.LoadNatures.Add(nature);
                    LoadNaturesMap newLoadNaturesMap = new LoadNaturesMap(nature);
                    m_dataBuffer.LoadNaturesMap.Add(newLoadNaturesMap);
                }
            }
            elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadCase)).ToElements();
            foreach (Element e in elements)
            {
                //get all the loadcases
                LoadCase loadCase = e as LoadCase;
                if (null != loadCase)
                {
                    m_dataBuffer.LoadCases.Add(loadCase);
                    LoadCasesMap newLoadCaseMap = new LoadCasesMap(loadCase);
                    m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// add a new load nature
        /// </summary>
        /// <param name="index">the selected nature's index in the nature map</param>
        /// <returns></returns>
        public bool AddLoadNature(int index)
        {
            string         natureName   = null;  //the load nature's name to be added
            bool           isUnique     = false; // check if the name is unique
            LoadNaturesMap myLoadNature = null;

            //try to get out the loadnature from the map
            try
            {
                myLoadNature = m_dataBuffer.LoadNaturesMap[index];
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation += e.ToString();
                return(false);
            }

            //Can not get the load nature
            if (null == myLoadNature)
            {
                m_dataBuffer.ErrorInformation += "Can't find the nature";
                return(false);
            }

            //check if the name is unique
            natureName = myLoadNature.LoadNaturesName;
            while (!isUnique)
            {
                natureName += "(1)";
                isUnique    = IsNatureNameUnique(natureName);
            }

            //try to create a load nature
            try
            {
                UIApplication uiapplication = new UIApplication(m_revit);
                LoadNature    newLoadNature = uiapplication.ActiveUIDocument.Document.Create.NewLoadNature(natureName);
                if (null == newLoadNature)
                {
                    m_dataBuffer.ErrorInformation += "Create Failed";
                    return(false);
                }

                //add the load nature into the list and maps
                m_dataBuffer.LoadNatures.Add(newLoadNature);
                LoadNaturesMap newMap = new LoadNaturesMap(newLoadNature);
                m_dataBuffer.LoadNaturesMap.Add(newMap);
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation += e.ToString();
                return(false);
            }
            return(true);
        }
Exemple #3
0
        /***************************************************/
        /***    Helper Methods                           ***/
        /***************************************************/

        private eLoadPatternType LoadNatureToCSI(LoadNature loadNature)
        {
            eLoadPatternType loadType;

            switch (loadNature)
            {
            case LoadNature.Dead:
                loadType = eLoadPatternType.Dead;
                break;

            case LoadNature.SuperDead:
                loadType = eLoadPatternType.SuperDead;
                break;

            case LoadNature.Live:
                loadType = eLoadPatternType.Live;
                break;

            case LoadNature.Wind:
                loadType = eLoadPatternType.Dead;
                break;

            case LoadNature.Seismic:
                loadType = eLoadPatternType.Quake;
                break;

            case LoadNature.Temperature:
                loadType = eLoadPatternType.Temperature;
                break;

            case LoadNature.Snow:
                loadType = eLoadPatternType.Snow;
                break;

            case LoadNature.Accidental:
                loadType = eLoadPatternType.Braking;
                break;

            case LoadNature.Prestress:
                loadType = eLoadPatternType.Prestress;
                break;

            case LoadNature.Other:
                loadType = eLoadPatternType.Other;
                break;

            default:
                loadType = eLoadPatternType.Other;
                break;
            }

            return(loadType);
        }
Exemple #4
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static eLoadPatternType ToCSI(this LoadNature loadNature)
        {
            eLoadPatternType patType = new eLoadPatternType();

            switch (loadNature)
            {
            case LoadNature.Dead:
                patType = eLoadPatternType.Dead;
                break;

            case LoadNature.SuperDead:
                patType = eLoadPatternType.SuperDead;
                break;

            case LoadNature.Live:
                patType = eLoadPatternType.Live;
                break;

            case LoadNature.Seismic:
                patType = eLoadPatternType.Quake;
                break;

            case LoadNature.Wind:
                patType = eLoadPatternType.Wind;
                break;

            case LoadNature.Snow:
                patType = eLoadPatternType.Snow;
                break;

            case LoadNature.Other:
                patType = eLoadPatternType.Other;
                break;

            case LoadNature.Temperature:
                patType = eLoadPatternType.Temperature;
                break;

            case LoadNature.Notional:
                patType = eLoadPatternType.Notional;
                break;

            case LoadNature.Prestress:
                patType = eLoadPatternType.Prestress;
                break;

            default:
                patType = eLoadPatternType.Other;
                break;
            }

            return(patType);
        }
Exemple #5
0
        /// <summary>
        /// prepare data for the dialog
        /// </summary>
        public void PrepareData()
        {
            //Create seven Load Natures first
            if (!CreateLoadNatures())
            {
                return;
            }

            //get all the categories of load cases
            UIApplication   uiapplication   = new UIApplication(m_revit);
            Categories      categories      = uiapplication.ActiveUIDocument.Document.Settings.Categories;
            Category        category        = categories.get_Item(BuiltInCategory.OST_LoadCases);
            CategoryNameMap categoryNameMap = category.SubCategories;

            System.Collections.IEnumerator iter = categoryNameMap.GetEnumerator();
            iter.Reset();
            while (iter.MoveNext())
            {
                Category temp = iter.Current as Category;
                if (null == temp)
                {
                    continue;
                }
                m_dataBuffer.LoadCasesCategory.Add(temp);
            }

            //get all the loadnatures name
            IList <Element> elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadNature)).ToElements();

            foreach (Element e in elements)
            {
                LoadNature nature = e as LoadNature;
                if (null != nature)
                {
                    m_dataBuffer.LoadNatures.Add(nature);
                    LoadNaturesMap newLoadNaturesMap = new LoadNaturesMap(nature);
                    m_dataBuffer.LoadNaturesMap.Add(newLoadNaturesMap);
                }
            }
            elements = new FilteredElementCollector(uiapplication.ActiveUIDocument.Document).OfClass(typeof(LoadCase)).ToElements();
            foreach (Element e in elements)
            {
                //get all the loadcases
                LoadCase loadCase = e as LoadCase;
                if (null != loadCase)
                {
                    m_dataBuffer.LoadCases.Add(loadCase);
                    LoadCasesMap newLoadCaseMap = new LoadCasesMap(loadCase);
                    m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
                }
            }
        }
Exemple #6
0
        private static int St7LoadCaseTypeFromNature(LoadNature loadNature)
        {
            switch (loadNature)
            {
            case LoadNature.Seismic:
                return(St7.lcSeismic);

            case LoadNature.Notional:
                return(St7.lcAccelerations);

            default:
                return(St7.lcNoInertia);
            }
        }
Exemple #7
0
 /// <summary>
 /// create some load case natures named EQ1, EQ2, W1, W2, W3, W4, Other
 /// </summary>
 /// <returns></returns>
 private bool CreateLoadNatures()
 {
     //try to add some new load natures
     try
     {
         UIApplication uiapplication = new UIApplication(m_revit);
         foreach (string name in m_newLoadNaturesName)
         {
             LoadNature.Create(uiapplication.ActiveUIDocument.Document, name);
         }
     }
     catch (Exception e)
     {
         m_dataBuffer.ErrorInformation += e.ToString();
         return(false);
     }
     return(true);
 }
Exemple #8
0
        private static rf.ActionCategoryType GetLoadCategory(LoadNature loadNature)
        {
            switch (loadNature)
            {
            case LoadNature.Dead:
                return(rf.ActionCategoryType.DeadLoad);

            case LoadNature.SuperDead:
                return(rf.ActionCategoryType.OtherCategory);   //TODO: What is super dead load in RFEM terminology??

            case LoadNature.Live:
                return(rf.ActionCategoryType.Live);

            case LoadNature.Wind:
                return(rf.ActionCategoryType.Wind);

            case LoadNature.Seismic:
                return(rf.ActionCategoryType.Earthquake);

            case LoadNature.Temperature:
                return(rf.ActionCategoryType.UniformTemperatures);

            case LoadNature.Snow:
                return(rf.ActionCategoryType.Snow);

            case LoadNature.Accidental:
                return(rf.ActionCategoryType.Accidental);

            case LoadNature.Prestress:
                return(rf.ActionCategoryType.Prestress);

            case LoadNature.Notional:
                return(rf.ActionCategoryType.OtherCategory);

            case LoadNature.Other:
                return(rf.ActionCategoryType.OtherCategory);

            default:
                return(rf.ActionCategoryType.UnknownActionCategory);
            }
        }
Exemple #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="app"></param>
        /// <param name="element"></param>
        /// <returns></returns>
        public static Revit.Element CloneElement(Application app, Revit.Element element)
        {
            Opening opening = element as Opening;

            if (opening != null)
            {
                return(CloneElement(app, opening));
            }

            BoundaryConditions boundaryConditions = element as BoundaryConditions;

            if (boundaryConditions != null)
            {
                return(CloneElement(app, boundaryConditions));
            }

            AreaLoad areaLoad = element as AreaLoad;

            if (areaLoad != null)
            {
                return(CloneElement(app, areaLoad));
            }

            AreaReinforcement areaReinforcement = element as AreaReinforcement;

            if (areaReinforcement != null)
            {
                return(CloneElement(app, areaReinforcement));
            }

            BeamSystem beamSystem = element as BeamSystem;

            if (beamSystem != null)
            {
                return(CloneElement(app, beamSystem));
            }

            Dimension dimension = element as Dimension;

            if (dimension != null)
            {
                return(CloneElement(app, dimension));
            }

            FamilyInstance familyInstance = element as FamilyInstance;

            if (familyInstance != null)
            {
                return(CloneElement(app, familyInstance));
            }

            Floor floor = element as Floor;

            if (floor != null)
            {
                return(CloneElement(app, floor));
            }

            Grid grid = element as Grid;

            if (grid != null)
            {
                return(CloneElement(app, grid));
            }

            Group group = element as Group;

            if (group != null)
            {
                return(CloneElement(app, group));
            }

            Level level = element as Level;

            if (floor != null)
            {
                return(CloneElement(app, floor));
            }

            LineLoad lineLoad = element as LineLoad;

            if (lineLoad != null)
            {
                return(CloneElement(app, lineLoad));
            }

            LoadCase loadCase = element as LoadCase;

            if (loadCase != null)
            {
                return(CloneElement(app, loadCase));
            }

            LoadCombination loadCombination = element as LoadCombination;

            if (loadCombination != null)
            {
                return(CloneElement(app, loadCombination));
            }

            LoadNature loadNature = element as LoadNature;

            if (loadNature != null)
            {
                return(CloneElement(app, loadNature));
            }

            LoadUsage loadUsage = element as LoadUsage;

            if (loadUsage != null)
            {
                return(CloneElement(app, loadUsage));
            }

            ModelCurve modelCurve = element as ModelCurve;

            if (modelCurve != null)
            {
                return(CloneElement(app, modelCurve));
            }

            PointLoad pointLoad = element as PointLoad;

            if (pointLoad != null)
            {
                return(CloneElement(app, pointLoad));
            }

            Rebar rebar = element as Rebar;

            if (rebar != null)
            {
                return(CloneElement(app, rebar));
            }

            ReferencePlane referencePlane = element as ReferencePlane;

            if (referencePlane != null)
            {
                return(CloneElement(app, referencePlane));
            }

            Room room = element as Room;

            if (room != null)
            {
                return(CloneElement(app, room));
            }

            RoomTag roomTag = element as RoomTag;

            if (roomTag != null)
            {
                return(CloneElement(app, roomTag));
            }

            SketchPlane sketchPlane = element as SketchPlane;

            if (sketchPlane != null)
            {
                return(CloneElement(app, sketchPlane));
            }

            View3D view3D = element as View3D;

            if (view3D != null)
            {
                return(CloneElement(app, view3D));
            }

            ViewDrafting viewDrafting = element as ViewDrafting;

            if (viewDrafting != null)
            {
                return(CloneElement(app, viewDrafting));
            }

            ViewSection viewSection = element as ViewSection;

            if (viewSection != null)
            {
                return(CloneElement(app, viewSection));
            }

            ViewSheet viewSheet = element as ViewSheet;

            if (viewSheet != null)
            {
                return(CloneElement(app, viewSheet));
            }

            Wall wall = element as Wall;

            if (wall != null)
            {
                return(CloneElement(app, wall));
            }

            // this element has not yet been exposed in the Creation Document class
            //Debug.Assert(false);

            return(null);
        }
        private void Stream( ArrayList data, LoadNature loadNature )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( LoadNature ) ) );

              // Nothing at this level yet!
        }
Exemple #11
0
        /// <summary>
        /// Duplicate a new load case
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public bool DuplicateLoadCase(int index)
        {
            LoadCasesMap myLoadCase = null;
            bool         isUnique   = false;
            string       caseName   = null;

            //try to get the load case from the map
            try
            {
                myLoadCase = m_dataBuffer.LoadCasesMap[index];
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation += e.ToString();
                return(false);
            }

            //get nothing
            if (null == myLoadCase)
            {
                m_dataBuffer.ErrorInformation += "Can not find the load case";
                return(false);
            }

            //check the name
            caseName = myLoadCase.LoadCasesName;
            while (!isUnique)
            {
                caseName += "(1)";
                isUnique  = IsCaseNameUnique(caseName);
            }

            //get the selected case's nature
            Category   caseCategory = null;
            LoadNature caseNature   = null;

            Autodesk.Revit.DB.ElementId categoryId = myLoadCase.LoadCasesCategoryId;
            Autodesk.Revit.DB.ElementId natureId   = myLoadCase.LoadCasesNatureId;

            UIApplication uiapplication = new UIApplication(m_revit);

            caseNature = uiapplication.ActiveUIDocument.Document.get_Element(natureId) as LoadNature;

            //get the selected case's category
            Categories      categories      = uiapplication.ActiveUIDocument.Document.Settings.Categories;
            Category        category        = categories.get_Item(BuiltInCategory.OST_LoadCases);
            CategoryNameMap categoryNameMap = category.SubCategories;

            System.Collections.IEnumerator iter = categoryNameMap.GetEnumerator();
            iter.Reset();
            while (iter.MoveNext())
            {
                Category tempC = iter.Current as Category;
                if (null != tempC && (categoryId.IntegerValue == tempC.Id.IntegerValue))
                {
                    caseCategory = tempC;
                    break;
                }
            }

            //check if lack of the information
            if (null == caseNature || null == caseCategory || null == caseName)
            {
                m_dataBuffer.ErrorInformation += "Can't find the load case";
                return(false);
            }

            //try to create a load case
            try
            {
                LoadCase newLoadCase = uiapplication.ActiveUIDocument.Document.Create.NewLoadCase(caseName, caseNature, caseCategory);
                if (null == newLoadCase)
                {
                    m_dataBuffer.ErrorInformation += "Create Load Case Failed";
                    return(false);
                }
                //add the new case into list and map
                m_dataBuffer.LoadCases.Add(newLoadCase);
                LoadCasesMap newLoadCaseMap = new LoadCasesMap(newLoadCase);
                m_dataBuffer.LoadCasesMap.Add(newLoadCaseMap);
            }
            catch (Exception e)
            {
                m_dataBuffer.ErrorInformation += e.ToString();
                return(false);
            }
            return(true);
        }
Exemple #12
0
 public static Loadcase Loadcase(string name, int number, LoadNature nature = LoadNature.Other)
 {
     return(new Loadcase {
         Name = name, Number = number, Nature = nature
     });
 }
 /// <summary>
 /// constructor of LoadNaturesMap class
 /// </summary>
 /// <param name="loadNature"></param>
 public LoadNaturesMap(LoadNature loadNature)
 {
     m_loadNature      = loadNature;
     m_loadNaturesName = loadNature.Name;
 }
Exemple #14
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static LoadNature ToBHoM(this eLoadPatternType patType)
        {
            LoadNature nature = new LoadNature();

            switch (patType)
            {
            case eLoadPatternType.Dead:
                nature = LoadNature.Dead;
                break;

            case eLoadPatternType.SuperDead:
                nature = LoadNature.SuperDead;
                break;

            case eLoadPatternType.Live:
                nature = LoadNature.Live;
                break;

            case eLoadPatternType.Quake:
                nature = LoadNature.Seismic;
                break;

            case eLoadPatternType.Wind:
                nature = LoadNature.Wind;
                break;

            case eLoadPatternType.Snow:
                nature = LoadNature.Snow;
                break;

            case eLoadPatternType.Other:
                nature = LoadNature.Other;
                break;

            case eLoadPatternType.Temperature:
                nature = LoadNature.Temperature;
                break;

            case eLoadPatternType.Rooflive:
                nature = LoadNature.Live;
                break;

            case eLoadPatternType.Notional:
                nature = LoadNature.Notional;
                break;

            case eLoadPatternType.PatternLive:
                nature = LoadNature.Live;
                break;

            case eLoadPatternType.TemperatureGradient:
                nature = LoadNature.Temperature;
                break;

            case eLoadPatternType.Prestress:
                nature = LoadNature.Prestress;
                break;

            default:
                nature = LoadNature.Other;
                break;
            }

            return(nature);
        }
Exemple #15
0
 /// <summary>
 /// constructor of LoadNaturesMap class 
 /// </summary>
 /// <param name="loadNature"></param>
 public LoadNaturesMap(LoadNature loadNature)
 {
     m_loadNature = loadNature;
     m_loadNaturesName = loadNature.Name;
 }