Exemplo n.º 1
0
        public ModelUnits UnitsToSpeckle()
        {
            var modelUnits = new ModelUnits();
            var units      = Model.GetDatabaseUnits();

            if (units != 0)
            {
                string[] unitsCat = units.ToString().Split('_');
                modelUnits.temperature = unitsCat[2];
                modelUnits.length      = unitsCat[1];
                modelUnits.force       = unitsCat[0];
            }
            else
            {
                //TO DO: custom units
            }
            return(modelUnits);
        }
        public List <WallForceResult> GetPierForces(string ComboName, PierPointLocation PierPointLocation, ModelUnits ModelUnits)
        {
            List <WallForceResult> results = new List <WallForceResult>();

            EtabsModel.Results.Setup.DeselectAllCasesAndCombosForOutput();
            switch (ModelUnits)
            {
            case ModelUnits.kip_in:

                EtabsModel.SetPresentUnits(eUnits.kip_in_F);
                break;

            case ModelUnits.kip_ft:
                EtabsModel.SetPresentUnits(eUnits.kip_ft_F);
                break;

            default:
                EtabsModel.SetPresentUnits(eUnits.kip_in_F);
                break;
            }

            var ret1 = EtabsModel.Results.Setup.SetComboSelectedForOutput(ComboName);


            int NumberResults = 0;

            string[] _StoryNames = null;
            string[] _PierNames  = null;
            string[] _Locations  = null;
            string[] _LoadCase   = null;
            double[] _P          = null;
            double[] _V2         = null;
            double[] _V3         = null;
            double[] _T          = null;
            double[] _M2         = null;
            double[] _M3         = null;


            var ret2 = EtabsModel.Results.PierForce(
                ref NumberResults,
                ref _StoryNames,
                ref _PierNames,
                ref _LoadCase,
                ref _Locations,
                ref _P,
                ref _V2,
                ref _V3,
                ref _T,
                ref _M2,
                ref _M3
                );



            List <PierDataPoint> unfilteredList = new List <PierDataPoint>();

            if (NumberResults > 0)
            {
                for (int i = 0; i < NumberResults; i++)
                {
                    PierDataPoint dp = new PierDataPoint()
                    {
                        StoryName = _StoryNames[i],
                        PierName  = _PierNames[i],
                        LoadCase  = _LoadCase[i],
                        Location  = _Locations[i],
                        P         = _P[i],
                        V2        = _V2[i],
                        V3        = _V3[i],
                        T         = _T[i],
                        M2        = _M2[i],
                        M3        = _M3[i]
                    };

                    unfilteredList.Add(dp);
                }

                //Unique storys
                List <string> StoryNames = _StoryNames.Distinct().ToList();
                // Unique piers
                List <string> PierNames = _PierNames.Distinct().ToList();

                if (StoryNames.Count != 0 && PierNames.Count != 0)
                {
                    foreach (var pier in PierNames)
                    {
                        var thisPierStoryOccurence = unfilteredList.Where(w => w.PierName == pier).Select(p => p.StoryName);
                        var storiesForThisPier     = thisPierStoryOccurence.Distinct().ToList();

                        foreach (var story in storiesForThisPier)
                        {
                            var    PierData = unfilteredList.Where(w => w.StoryName == story && w.PierName == pier && w.Location == PierPointLocation.ToString());
                            double P_Max    = PierData.Max(p => p.P);
                            double V2_Max   = PierData.Max(p => p.V2);
                            double V3_Max   = PierData.Max(p => p.V3);
                            double T_Max    = PierData.Max(p => p.T);
                            double M2_Max   = PierData.Max(p => p.M2);
                            double M3_Max   = PierData.Max(p => p.M3);
                            double P_Min    = PierData.Min(p => p.P);
                            double V2_Min   = PierData.Min(p => p.V2);
                            double V3_Min   = PierData.Min(p => p.V3);
                            double T_Min    = PierData.Min(p => p.T);
                            double M2_Min   = PierData.Min(p => p.M2);
                            double M3_Min   = PierData.Min(p => p.M3);

                            WallPointResult res = new WallPointResult()
                            {
                                P_Max             = P_Max,
                                V2_Max            = V2_Max,
                                V3_Max            = V3_Max,
                                T_Max             = T_Max,
                                M2_Max            = M2_Max,
                                M3_Max            = M3_Max,
                                P_Min             = P_Min,
                                V2_Min            = V2_Min,
                                V3_Min            = V3_Min,
                                T_Min             = T_Min,
                                M2_Min            = M2_Min,
                                M3_Min            = M3_Min,
                                StoryName         = story,
                                PierPointLocation = PierPointLocation
                            };

                            WallForceResult forceResult = new WallForceResult()
                            {
                                PierName = pier,
                                Result   = res
                            };
                            results.Add(forceResult);
                        }
                    }
                    return(results);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        public List <PierData> GetAllPierGeometry(ModelUnits ModelUnits)
        {
            List <PierData> AllPiers = new List <PierData>();

            //SET UP CORRECT UNITS
            EtabsModel.Results.Setup.DeselectAllCasesAndCombosForOutput();
            switch (ModelUnits)
            {
            case ModelUnits.kip_in:
                EtabsModel.SetPresentUnits(eUnits.kip_in_F);
                break;

            case ModelUnits.kip_ft:
                EtabsModel.SetPresentUnits(eUnits.kip_ft_F);
                break;

            default:
                EtabsModel.SetPresentUnits(eUnits.kip_in_F);
                break;
            }


            //EXTRACT PIER NAMES
            int NumNames = 0;

            string[] _UniquePierNames = null;
            int      res = EtabsModel.PierLabel.GetNameList(ref NumNames, ref _UniquePierNames);

            if (NumNames > 0)
            {
            }
            else
            {
                throw new Exception("Failed to exctract pier names. Check if ETABS model is available for reading.");
            }
            List <string> UniquePierNames = new List <string>(_UniquePierNames);

            //EXTRACT PIER GEOMETRY


            #region temporary arrays
            int      _NumberStories = 0;
            string[] _StoryName     = null;
            double[] _AxisAngle     = null;
            int[]    _NumAreaObjs   = null;
            int[]    _NumLineObjs   = null;
            double[] _WidthBot      = null;
            double[] _ThicknessBot  = null;
            double[] _WidthTop      = null;
            double[] _ThicknessTop  = null;
            string[] _MatProp       = null;
            double[] _CGBotX        = null;
            double[] _CGBotY        = null;
            double[] _CGBotZ        = null;
            double[] _CGTopX        = null;
            double[] _CGTopY        = null;
            double[] _CGTopZ        = null;

            #endregion


            foreach (var pierName in UniquePierNames)
            {
                List <PierStoryData> thisPierData = new List <PierStoryData>();
                var ret1 = EtabsModel.PierLabel.GetSectionProperties(pierName, ref _NumberStories, ref _StoryName, ref _AxisAngle, ref _NumAreaObjs, ref _NumLineObjs,
                                                                     ref _WidthBot, ref _ThicknessBot, ref _WidthTop, ref _ThicknessTop, ref _MatProp, ref _CGBotX, ref _CGBotY, ref _CGBotZ, ref _CGTopX, ref _CGTopY, ref _CGTopZ
                                                                     );
                for (int i = 0; i < _NumberStories; i++)
                {
                    string        a             = _MatProp[i];
                    PierStoryData thisStoryData = new PierStoryData(pierName,
                                                                    _NumberStories,
                                                                    _StoryName[i],
                                                                    _AxisAngle[i],
                                                                    _NumAreaObjs[i],
                                                                    _NumLineObjs[i],
                                                                    _WidthBot[i],
                                                                    _ThicknessBot[i],
                                                                    _WidthTop[i],
                                                                    _ThicknessTop[i],
                                                                    _MatProp[i],
                                                                    _CGBotX[i],
                                                                    _CGBotY[i],
                                                                    _CGBotZ[i],
                                                                    _CGTopX[i],
                                                                    _CGTopY[i],
                                                                    _CGTopZ[i]);
                    thisPierData.Add(thisStoryData);
                }
                PierData data = new PierData(pierName, thisPierData);
                AllPiers.Add(data);
            }

            return(AllPiers);
        }
        public FrameEnvelopeReactionResult GetFrameReactions(string GroupName, string ComboName, ModelUnits ModelUnits)
        {
            //FrameForceExtractor ext = new FrameForceExtractor(model);
            //FrameEnvelopeReactionResult res = ext.GetFrameReactions(GroupName, ComboName, ModelUnits);
            FrameDataExtractor          ext = new FrameDataExtractor();
            FrameEnvelopeReactionResult res = ext.GetFrameReactions(GroupName, ComboName, ModelUnits.ToString());

            return(res);
        }
        public List <WallForceResult> GetPierForces(string PierName, string ComboName, PierPointLocation PierPointLocation, ModelUnits ModelUnits)
        {
            PierForceExtractor     ext = new PierForceExtractor(model);
            List <WallForceResult> f   = ext.GetPierForces(ComboName, PierPointLocation, ModelUnits);
            var thisPierForces         = f.Where(p => p.PierName == PierName).ToList();

            return(thisPierForces);
        }
        public List <WallForceResult> GetPierForces(string ComboName, PierPointLocation PierPointLocation, ModelUnits ModelUnits)
        {
            model = ETABSConnection.GetModel();
            PierForceExtractor     ext = new PierForceExtractor(model);
            List <WallForceResult> f   = ext.GetPierForces(ComboName, PierPointLocation, ModelUnits);

            model = null;
            return(f);
        }
        public List <WallComboResult> GetAllComboPierForces(List <string> comboNames, ModelUnits ModelUnits)
        {
            PierForceExtractor ext = new PierForceExtractor(model);
            //List<string> comboNames = this.GetModelComboNames();

            List <WallComboResult> combinedList = new List <WallComboResult>();

            foreach (var comboName in comboNames)
            {
                List <WallForceResult> BottomLoc       = GetPierForces(comboName, PierPointLocation.Bottom, Interop.ModelUnits.kip_in);
                List <WallForceResult> BottomTop       = GetPierForces(comboName, PierPointLocation.Top, Interop.ModelUnits.kip_in);
                List <WallForceResult> thisComboResult = BottomLoc.Concat(BottomTop).ToList();

                combinedList.Add(new WallComboResult(comboName, thisComboResult));
            }

            return(combinedList);
        }
Exemplo n.º 8
0
        public void UnitsToNative(ModelUnits units)
        {
            var force  = eForce.NotApplicable;
            var length = eLength.NotApplicable;
            var temp   = eTemperature.NotApplicable;

            switch (units.force)
            {
            case "N":
                force = eForce.N;
                break;

            case "kip":
                force = eForce.kip;
                break;

            case "kN":
                force = eForce.kN;
                break;

            case "lb":
                force = eForce.lb;
                break;

            case "tf":
                force = eForce.tonf;
                break;

            default:
                force = eForce.NotApplicable;
                break;
            }
            switch (units.length)
            {
            case "m":
                length = eLength.m;
                break;

            case "in":
                length = eLength.inch;
                break;

            case "cm":
                length = eLength.cm;
                break;

            case "mm":
                length = eLength.mm;
                break;

            case "ft":
                length = eLength.ft;
                break;

            default:
                length = eLength.NotApplicable;
                break;
            }
            switch (units.temperature)
            {
            case "C":
                temp = eTemperature.C;
                break;

            case "F":
                temp = eTemperature.F;
                break;

            default:
                temp = eTemperature.NotApplicable;
                break;
            }
            Model.SetPresentUnits_2(force, length, temp);
            return;
        }
Exemplo n.º 9
0
        public FrameEnvelopeForceResult GetFrameForcesAtStationRatio(List <string> FrameNames, string ComboName, ModelUnits ModelUnits, double StationRatio)
        {
            //Set Units
            switch (ModelUnits)
            {
            case ModelUnits.kip_in:

                EtabsModel.SetPresentUnits(eUnits.kip_in_F);
                break;

            case ModelUnits.kip_ft:
                EtabsModel.SetPresentUnits(eUnits.kip_ft_F);
                break;

            default:
                EtabsModel.SetPresentUnits(eUnits.kip_in_F);
                break;
            }


            FrameForceResult         thisSelectionResult         = GetEnvelopeForceResultForMultipleFrames(FrameNames, ComboName, StationRatio);
            FrameEnvelopeForceResult thisSelectionEnvelopeResult = new FrameEnvelopeForceResult(null, thisSelectionResult);

            return(thisSelectionEnvelopeResult);
        }
Exemplo n.º 10
0
        public List <FrameEnvelopeReactionResult> GetFrameReactions(List <string> FrameNames, string GroupNamePrefix, string ComboName, ModelUnits ModelUnits)
        {
            //Set Units
            switch (ModelUnits)
            {
            case ModelUnits.kip_in:

                EtabsModel.SetPresentUnits(eUnits.kip_in_F);
                break;

            case ModelUnits.kip_ft:
                EtabsModel.SetPresentUnits(eUnits.kip_ft_F);
                break;

            default:
                EtabsModel.SetPresentUnits(eUnits.kip_in_F);
                break;
            }
            List <FrameEnvelopeReactionResult> frameForceResult = new List <FrameEnvelopeReactionResult>();

            List <GroupData> GroupData = ExtractGroupNames(FrameNames, GroupNamePrefix);

            if (GroupData != null)
            {
                foreach (var g in GroupData)
                {
                    FrameReactionResult         thisGroupResult         = GetEnvelopeReactionResultForMultipleFrames(g.Elements, ComboName);
                    FrameEnvelopeReactionResult thisGroupEnvelopeResult = new FrameEnvelopeReactionResult(g.Name, thisGroupResult);
                    frameForceResult.Add(thisGroupEnvelopeResult);
                }
            }
            return(frameForceResult);
        }
Exemplo n.º 11
0
        public FrameEnvelopeReactionResult GetFrameReactions(string GroupName, string ComboName, ModelUnits ModelUnits)
        {
            //Set Units
            switch (ModelUnits)
            {
            case ModelUnits.kip_in:

                EtabsModel.SetPresentUnits(eUnits.kip_in_F);
                break;

            case ModelUnits.kip_ft:
                EtabsModel.SetPresentUnits(eUnits.kip_ft_F);
                break;

            default:
                EtabsModel.SetPresentUnits(eUnits.kip_in_F);
                break;
            }
            List <FrameEnvelopeReactionResult> frameForceResult = new List <FrameEnvelopeReactionResult>();

            GroupManager gm = new GroupManager(EtabsModel);
            GroupData    d  = gm.GetGroupDataForFrames(GroupName);

            FrameReactionResult         thisGroupResult         = GetEnvelopeReactionResultForMultipleFrames(d.Elements, ComboName);
            FrameEnvelopeReactionResult thisGroupEnvelopeResult = new FrameEnvelopeReactionResult(d.Name, thisGroupResult);


            return(thisGroupEnvelopeResult);
        }
Exemplo n.º 12
0
        internal XElement ToXElement(Package package)
        {
            // ensure build items are included
            var resourcesHash = new HashSet <ThreeMfResource>(Resources);

            foreach (var item in Items)
            {
                if (resourcesHash.Add(item.Object))
                {
                    Resources.Add(item.Object);
                }
            }

            // ensure components and property resources are included
            foreach (var resource in Resources.ToList())
            {
                if (resource is ThreeMfObject obj)
                {
                    foreach (var component in obj.Components)
                    {
                        if (resourcesHash.Add(component.Object))
                        {
                            // components must be defined ahead of their reference
                            Resources.Insert(0, component.Object);
                        }
                    }

                    if (obj.PropertyResource != null && resourcesHash.Add((ThreeMfResource)obj.PropertyResource))
                    {
                        // property resources must be defined ahead of their reference
                        Resources.Insert(0, (ThreeMfResource)obj.PropertyResource);
                    }

                    foreach (var triangle in obj.Mesh.Triangles)
                    {
                        if (triangle.PropertyResource != null && resourcesHash.Add((ThreeMfResource)triangle.PropertyResource))
                        {
                            // property resources must be defined ahead of their reference
                            Resources.Insert(0, (ThreeMfResource)triangle.PropertyResource);
                        }
                    }
                }
                else if (resource is ThreeMfTexture2DGroup textureGroup)
                {
                    if (resourcesHash.Add(textureGroup.Texture))
                    {
                        // textures must be defined ahead of their reference
                        Resources.Insert(0, textureGroup.Texture);
                    }
                }
            }

            var resourceMap = new Dictionary <ThreeMfResource, int>();

            for (int i = 0; i < Resources.Count; i++)
            {
                Resources[i].Id = i + 1;
                resourceMap.Add(Resources[i], Resources[i].Id);
            }

            var modelXml = new XElement(ModelName);

            // ensure all appropriate namespaces are included
            var extensionNamespaces = new List <Tuple <string, string> >();

            if (Resources.Any(r => r is ThreeMfColorGroup || r is ThreeMfTexture2D || r is ThreeMfTexture2DGroup))
            {
                extensionNamespaces.Add(Tuple.Create(MaterialNamespace, "m"));
            }

            modelXml.Add(
                new XAttribute(UnitAttributeName, ModelUnits.ToString().ToLowerInvariant()),
                new XAttribute(XmlLanguageAttributeName, DefaultLanguage),
                extensionNamespaces.Select(rns => new XAttribute(XNamespace.Xmlns + rns.Item2, rns.Item1)),
                GetMetadataXElements(Metadata_Title, Title),
                GetMetadataXElements(Metadata_Designer, Designer),
                GetMetadataXElements(Metadata_Description, Description),
                GetMetadataXElements(Metadata_Copyright, Copyright),
                GetMetadataXElements(Metadata_LicenseTerms, LicenseTerms),
                GetMetadataXElements(Metadata_Rating, Rating),
                GetMetadataXElements(Metadata_CreationDate, CreationDate),
                GetMetadataXElements(Metadata_ModificationDate, ModificationDate),
                new XElement(ResourcesName,
                             Resources.Select(r => r.ToXElement(resourceMap))),
                new XElement(BuildName,
                             Items.Select(i => i.ToXElement(resourceMap))));
            return(modelXml);
        }