예제 #1
0
        public static void SapToDynamo(ref cSapModel Model, string SecName, ref string MatProp, ref string filename)
        {
            long           ret      = 0;
            eFramePropType PropType = new eFramePropType();

            ret = Model.PropFrame.GetTypeOAPI(SecName, ref PropType);

            string nameinfile = string.Empty; // If the section property was imported from a property file, this is the name of that file. If the section property was not imported, this item is blank.
            int    color = 0;
            string notes = string.Empty;
            string Guid = string.Empty;
            double t2 = 0; double t3 = 0; double TW = 0; double TF = 0; double t2b = 0; double t3b = 0;

            if (PropType == eFramePropType.Rectangular)
            {
                ret = Model.PropFrame.GetRectangle(SecName, ref filename, ref MatProp, ref t3, ref t2, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.Pipe)
            {
                ret = Model.PropFrame.GetPipe(SecName, ref filename, ref MatProp, ref t3, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.Circle)
            {
                ret = Model.PropFrame.GetCircle(SecName, ref filename, ref MatProp, ref t3, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.Box)
            {
                ret = Model.PropFrame.GetTube(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.I)
            {
                ret = Model.PropFrame.GetISection(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref t2b, ref t3b, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.Channel)
            {
                ret = Model.PropFrame.GetChannel(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.T)
            {
                ret = Model.PropFrame.GetTee(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.Angle)
            {
                ret = Model.PropFrame.GetAngle(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else
            {
                ret = Model.PropFrame.GetNameInPropFile(SecName, ref nameinfile, ref filename, ref MatProp, ref PropType);
            }

            if (!String.IsNullOrEmpty(filename))
            {
                filename = Path.GetFileNameWithoutExtension(filename);
            }
        }
예제 #2
0
        public static void SapToDynamo(ref cSapModel Model, string SecName, ref string MatProp, ref string filename)
        {
            long ret = 0;
            eFramePropType PropType = new eFramePropType();
            ret = Model.PropFrame.GetType(SecName, ref PropType);

            string nameinfile = string.Empty; // If the section property was imported from a property file, this is the name of that file. If the section property was not imported, this item is blank.
            int color = 0;
            string notes = string.Empty;
            string Guid = string.Empty;
            double t2 = 0; double t3 = 0; double TW = 0; double TF = 0; double t2b = 0; double t3b = 0;

            if (PropType == eFramePropType.SECTION_RECTANGULAR)
            {
                ret = Model.PropFrame.GetRectangle(SecName, ref filename, ref MatProp, ref t3, ref t2, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_PIPE)
            {
                ret = Model.PropFrame.GetPipe(SecName, ref filename, ref MatProp, ref t3, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_CIRCLE)
            {
                ret = Model.PropFrame.GetCircle(SecName, ref filename, ref MatProp, ref t3, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_BOX)
            {
                ret = Model.PropFrame.GetTube(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_I)
            {
                ret = Model.PropFrame.GetISection(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref t2b, ref t3b, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_CHANNEL)
            {
                ret = Model.PropFrame.GetChannel(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_T)
            {
                ret = Model.PropFrame.GetTee(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else if (PropType == eFramePropType.SECTION_ANGLE)
            {
                ret = Model.PropFrame.GetAngle(SecName, ref filename, ref MatProp, ref t3, ref t2, ref TF, ref TW, ref color, ref notes, ref Guid);
            }
            else
            {
                ret = Model.PropFrame.GetNameInPropFile(SecName, ref nameinfile, ref filename, ref MatProp, ref PropType);
            }

            if (!String.IsNullOrEmpty(filename))
            {
                filename = Path.GetFileNameWithoutExtension(filename);
            }
        }
예제 #3
0
        GetNameList(this cPropFrame obj, eFramePropType PropType = (eFramePropType)0)
        {
            int NumberNames;

            NumberNames = default(int);
            string[] MyName;
            MyName = default(string[]);
            var res = obj.GetNameList(ref NumberNames, ref MyName, PropType);

            return(NumberNames, MyName);
        }
예제 #4
0
        /***************************************************/

        private List <ISectionProperty> ReadSectionProperties(List <string> ids = null)
        {
            List <ISectionProperty> propList = new List <ISectionProperty>();
            int nameCount = 0;

            string[] names = { };

            if (ids == null)
            {
                m_model.PropFrame.GetNameList(ref nameCount, ref names);
                ids = names.ToList();
            }

            eFramePropType propertyType = eFramePropType.General;

            foreach (string id in ids)
            {
                m_model.PropFrame.GetTypeOAPI(id, ref propertyType);
                propList.Add(Helper.GetSectionProperty(m_model, id, propertyType));
            }
            return(propList);
        }
예제 #5
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <ISectionProperty> ReadSectionProperties(List <string> ids = null)
        {
            List <ISectionProperty> propList = new List <ISectionProperty>();
            Dictionary <string, IMaterialFragment> bhomMaterials = ReadMaterial().ToDictionary(x => GetAdapterId <string>(x));

            int nameCount = 0;

            string[] nameArr = { };
            m_model.PropFrame.GetNameList(ref nameCount, ref nameArr);

            ids = FilterIds(ids, nameArr);
            List <string> backLog = new List <string>();

            foreach (string id in ids)
            {
                eFramePropType   propertyType = eFramePropType.General;
                ISectionProperty bhomProperty = null;
                IProfile         bhomProfile  = null;
                SAP2000Id        sap2000id    = new SAP2000Id();

                sap2000id.Id = id;

                m_model.PropFrame.GetTypeOAPI(id, ref propertyType);

                string constructor = "standard";

                string materialName = "";
                string fileName = "";
                double t3 = 0;
                double t2 = 0;
                double tf = 0;
                double tw = 0;
                double tfb = 0;
                double t2b = 0;
                double dis = 0;
                double radius = 0;
                double angle = 0;
                int    color = 0;
                string notes = "";
                string guid = "";
                double Area, As2, As3, Torsion, I22, I33, S22, S33, Z22, Z33, R22, R33;
                Area = As2 = As3 = Torsion = I22 = I33 = S22 = S33 = Z22 = Z33 = R22 = R33 = 0;

                switch (propertyType)
                {
                case eFramePropType.I:
                    m_model.PropFrame.GetISection(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref t2b, ref tfb, ref color, ref notes, ref guid);
                    if (t2 == t2b)
                    {
                        bhomProfile = BH.Engine.Spatial.Create.ISectionProfile(t3, t2, tw, tf, 0, 0);
                    }
                    else
                    {
                        bhomProfile = BH.Engine.Spatial.Create.FabricatedISectionProfile(t3, t2, t2b, tw, tf, tfb, 0);
                    }
                    break;

                case eFramePropType.Channel:
                    m_model.PropFrame.GetChannel(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.ChannelProfile(t3, t2, tw, tf, 0, 0);
                    break;

                case eFramePropType.T:
                case eFramePropType.ConcreteTee:
                    m_model.PropFrame.GetTee(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.TSectionProfile(t3, t2, tw, tf);
                    break;

                case eFramePropType.Angle:
                case eFramePropType.Concrete_L:
                    m_model.PropFrame.GetAngle(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.AngleProfile(t3, t2, tw, tf, 0, 0);
                    break;

                case eFramePropType.DblAngle:
                    break;

                case eFramePropType.Box:
                case eFramePropType.ConcreteBox:
                    m_model.PropFrame.GetTube(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref color, ref notes, ref guid);
                    if (tf == tw)
                    {
                        bhomProfile = BH.Engine.Spatial.Create.BoxProfile(t3, t2, tf, 0, 0);
                    }
                    else
                    {
                        bhomProfile = BH.Engine.Spatial.Create.FabricatedBoxProfile(t3, t2, tw, tf, tf, 0);
                    }
                    break;

                case eFramePropType.Pipe:
                case eFramePropType.ConcretePipe:
                    m_model.PropFrame.GetPipe(id, ref fileName, ref materialName, ref t3, ref tw, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.TubeProfile(t3, tw);
                    break;

                case eFramePropType.Rectangular:
                case eFramePropType.SteelPlate:
                    m_model.PropFrame.GetRectangle(id, ref fileName, ref materialName, ref t3, ref t2, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.RectangleProfile(t3, t2, 0);
                    break;

                case eFramePropType.Auto:    //not member will have this assigned but it still exists in the propertyType list
                    bhomProfile = BH.Engine.Spatial.Create.CircleProfile(0.2);
                    break;

                case eFramePropType.Circle:
                case eFramePropType.SteelRod:
                    m_model.PropFrame.GetCircle(id, ref fileName, ref materialName, ref t3, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.CircleProfile(t3);
                    break;

                case eFramePropType.General:
                    m_model.PropFrame.GetGeneral(id, ref fileName, ref materialName, ref t3, ref t2, ref Area, ref As2, ref As3, ref Torsion, ref I22, ref I33, ref S22, ref S33, ref Z22, ref Z33, ref R22, ref R33, ref color, ref notes, ref guid);
                    constructor = "explicit";
                    break;

                case eFramePropType.Cold_Z:
                    m_model.PropFrame.GetColdZ(id, ref fileName, ref materialName, ref t3, ref t2, ref tw, ref radius, ref tfb, ref angle, ref color, ref notes, ref guid);
                    bhomProfile = BH.Engine.Spatial.Create.ZSectionProfile(t3, t2, tw, tw, radius, 0);
                    break;

                case eFramePropType.Variable:
                    if (!backLog.Contains(id))
                    {
                        //Can't read tapered sections until all other sections have been read.
                        backLog.Add(id);
                        continue;
                    }
                    break;

                case eFramePropType.DbChannel:
                case eFramePropType.SD:
                case eFramePropType.Joist:
                case eFramePropType.Bridge:
                case eFramePropType.Cold_C:
                case eFramePropType.Cold_2C:
                case eFramePropType.Cold_L:
                case eFramePropType.Cold_2L:
                case eFramePropType.Cold_Hat:
                case eFramePropType.BuiltupICoverplate:
                case eFramePropType.PCCGirderI:
                case eFramePropType.PCCGirderU:
                case eFramePropType.BuiltupIHybrid:
                case eFramePropType.BuiltupUHybrid:
                case eFramePropType.FilledTube:
                case eFramePropType.FilledPipe:
                case eFramePropType.EncasedRectangle:
                case eFramePropType.EncasedCircle:
                case eFramePropType.BucklingRestrainedBrace:
                case eFramePropType.CoreBrace_BRB:
                case eFramePropType.ConcreteCross:
                default:
                    break;
                }

                // Section Material

                IMaterialFragment material = null;
                if (!bhomMaterials.TryGetValue(materialName, out material))
                {
                    Engine.Base.Compute.RecordWarning($"Could not get material for SectionProperty {id}. A generic has been returned.");
                }

                if (bhomProfile == null)
                {
                    Engine.Base.Compute.RecordWarning("Reading sections of type " + propertyType.ToString() + " is not supported. An empty section with a default material has been returned.");
                    constructor = "explicit";
                }

                switch (constructor)
                {
                case "explicit":
                    bhomProperty = new ExplicitSection()
                    {
                        Area     = Area,
                        Asy      = As2,
                        Asz      = As3,
                        Iy       = I22,
                        Iz       = I33,
                        J        = Torsion,
                        Rgy      = R22,
                        Rgz      = R33,
                        Wply     = S22,
                        Wplz     = S33,
                        Wely     = Z22,
                        Welz     = Z33,
                        Material = material,
                        Name     = id
                    };
                    break;

                case "standard":
                    bhomProperty = BH.Engine.Structure.Create.SectionPropertyFromProfile(bhomProfile, material, id);
                    break;
                }

                // Apply Property Modifiers
                bhomProperty.Fragments.Add(ReadFrameSectionModifiers(id));

                // Apply the AdapterId
                bhomProperty.SetAdapterId(sap2000id);

                // Add to the list
                propList.Add(bhomProperty);
            }

            //Read any leftover sections (currently only tapered profiles)
            if (backLog.Count > 0)
            {
                foreach (string id in backLog)
                {
                    ISectionProperty bhomProperty = null;
                    SAP2000Id        sap2000id    = new SAP2000Id
                    {
                        Id = id
                    };

                    bhomProperty = ReadTaperedSection(id, propList);

                    bhomProperty.SetAdapterId(sap2000id);

                    bhomProperty.Fragments.Add(ReadFrameSectionModifiers(id));

                    propList.Add(bhomProperty);
                }
            }
            return(propList);
        }
예제 #6
0
        public SectionProfile SectionToSpeckle(string property)
        {
            var            speckleSectionProfile = new SectionProfile();
            eFramePropType propType            = eFramePropType.I;
            string         catalogue           = "";
            string         matProp             = "";
            string         sectionPropertyName = "";
            int            s = Model.PropFrame.GetNameInPropFile(property, ref sectionPropertyName, ref catalogue, ref matProp, ref propType);

            if (s == 0)
            {
                string[] arrayCatPath = catalogue.Split('\\');
                catalogue    = arrayCatPath.Last();
                arrayCatPath = catalogue.Split('.');
                catalogue    = arrayCatPath[0];
                switch (propType)
                {
                case eFramePropType.SD:
                    speckleSectionProfile = new Explicit();
                    break;

                default:
                    speckleSectionProfile = new Catalogue(property, catalogue, propType.ToString(), sectionPropertyName);
                    break;
                }

                return(speckleSectionProfile);
            }

            double T3       = 0;
            double T2       = 0;
            int    color    = 0;
            string notes    = "";
            string GUID     = "";
            string FileName = "";

            s = Model.PropFrame.GetRectangle(property, ref FileName, ref matProp, ref T3, ref T2, ref color, ref notes, ref GUID);

            if (s == 0)
            {
                speckleSectionProfile = new Rectangular(property, T3, T2);
            }

            double Tf           = 0;
            double TwF          = 0;
            double Twt          = 0;
            double Tw           = 0;
            bool   mirrorAbout3 = false;

            s = Model.PropFrame.GetConcreteTee(property, ref FileName, ref matProp, ref T3, ref T2, ref Tf, ref TwF, ref Twt, ref mirrorAbout3, ref color, ref notes, ref GUID);
            if (s == 0)
            {
                speckleSectionProfile = new Tee(property, T3, T2, TwF, Tf);
            }

            s = Model.PropFrame.GetCircle(property, ref FileName, ref matProp, ref T3, ref color, ref notes, ref GUID);
            if (s == 0)
            {
                speckleSectionProfile = new Circular(property, T3 / 2);
            }

            s = Model.PropFrame.GetAngle(property, ref FileName, ref matProp, ref T3, ref T2, ref Tf, ref Tw, ref color, ref notes, ref GUID);
            if (s == 0)
            {
                speckleSectionProfile = new Angle(property, T3, T2, Tw, Tf);
                return(speckleSectionProfile);
            }

            s = Model.PropFrame.GetChannel(property, ref FileName, ref matProp, ref T3, ref T2, ref Tf, ref Tw, ref color, ref notes, ref GUID);
            if (s == 0)
            {
                speckleSectionProfile = new Channel(property, T3, T2, Tw, Tf);
                return(speckleSectionProfile);
            }

            s = Model.PropFrame.GetTube(property, ref FileName, ref matProp, ref T3, ref T2, ref Tf, ref Tw, ref color, ref notes, ref GUID);
            if (s == 0)
            {
                speckleSectionProfile = new Rectangular(property, T3, T2, Tw, Tf);
                return(speckleSectionProfile);
            }

            s = Model.PropFrame.GetPipe(property, ref FileName, ref matProp, ref T3, ref Tw, ref color, ref notes, ref GUID);
            if (s == 0)
            {
                speckleSectionProfile = new Circular(property, T3, Tw);
                return(speckleSectionProfile);
            }
            return(null);
        }
예제 #7
0
        /***************************************************/

        private List <ISectionProperty> ReadSectionProperty(List <string> ids = null)
        {
            List <ISectionProperty> propList = new List <ISectionProperty>();
            Dictionary <String, IMaterialFragment> bhomMaterials = ReadMaterial().ToDictionary(x => x.DescriptionOrName());

            int nameCount = 0;

            string[] names = { };
            m_model.PropFrame.GetNameList(ref nameCount, ref names);

            ids = FilterIds(ids, names);

            eFramePropType propertyType = eFramePropType.General;

            List <string> backlog = new List <string>();

            do
            {
                foreach (string id in ids)
                {
                    m_model.PropFrame.GetTypeOAPI((string)id, ref propertyType);

                    ISectionProperty bhSectionProperty = null;
                    IProfile         dimensions        = null;
                    string           materialName      = "";

                    string fileName = "";
                    double t3       = 0;
                    double t2       = 0;
                    double tf       = 0;
                    double tw       = 0;
                    double twt      = 0;
                    double tfb      = 0;
                    double t2b      = 0;
                    int    colour   = 0;
                    string notes    = "";
                    string guid     = null;

                    bool verticalFlip = false;
                    bool horFlip      = false;

                    double Area, As2, As3, Torsion, I22, I33, S22, S33, Z22, Z33, R22, R33;
                    Area = As2 = As3 = Torsion = I22 = I33 = S22 = S33 = Z22 = Z33 = R22 = R33 = 0;

                    string constructSelector = "fromDimensions";

                    #region long switch on section property type
                    switch (propertyType)
                    {
                    case eFramePropType.I:
                        m_model.PropFrame.GetISection(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref t2b, ref tfb, ref colour, ref notes, ref guid);
                        if (t2 == t2b)
                        {
                            dimensions = Engine.Spatial.Create.ISectionProfile(t3, t2, tw, tf, 0, 0);
                        }
                        else
                        {
                            dimensions = Engine.Spatial.Create.FabricatedISectionProfile(t3, t2, t2b, tw, tf, tfb, 0);
                        }
                        break;

                    case eFramePropType.Channel:
                        m_model.PropFrame.GetChannel(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref colour, ref notes, ref guid);
                        dimensions = Engine.Spatial.Create.ChannelProfile(t3, t2, tw, tf, 0, 0);
                        break;

                    case eFramePropType.T:
                        break;

                    case eFramePropType.Angle:
                        m_model.PropFrame.GetAngle(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref colour, ref notes, ref guid);
                        dimensions = Engine.Spatial.Create.AngleProfile(t3, t2, tw, tf, 0, 0);
                        break;

                    case eFramePropType.DblAngle:
                        break;

                    case eFramePropType.Box:
                        m_model.PropFrame.GetTube(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref colour, ref notes, ref guid);
                        if (tf == tw)
                        {
                            dimensions = Engine.Spatial.Create.BoxProfile(t3, t2, tf, 0, 0);
                        }
                        else
                        {
                            dimensions = Engine.Spatial.Create.FabricatedBoxProfile(t3, t2, tw, tf, tf, 0);
                        }
                        break;

                    case eFramePropType.Pipe:
                        m_model.PropFrame.GetPipe(id, ref fileName, ref materialName, ref t3, ref tw, ref colour, ref notes, ref guid);
                        dimensions = Engine.Spatial.Create.TubeProfile(t3, tw);
                        break;

                    case eFramePropType.Rectangular:
                        m_model.PropFrame.GetRectangle(id, ref fileName, ref materialName, ref t3, ref t2, ref colour, ref notes, ref guid);
                        dimensions = Engine.Spatial.Create.RectangleProfile(t3, t2, 0);
                        break;

                    case eFramePropType.Auto:    //not member will have this assigned but it still exists in the propertyType list
                        dimensions = Engine.Spatial.Create.CircleProfile(0.2);
                        break;

                    case eFramePropType.Circle:
                        m_model.PropFrame.GetCircle(id, ref fileName, ref materialName, ref t3, ref colour, ref notes, ref guid);
                        dimensions = Engine.Spatial.Create.CircleProfile(t3);
                        break;

                    case eFramePropType.General:
                        constructSelector = "explicit";
                        m_model.PropFrame.GetGeneral(id, ref fileName, ref materialName, ref t3, ref t2, ref Area, ref As2, ref As3, ref Torsion, ref I22, ref I33, ref S22, ref S33, ref Z22, ref Z33, ref R22, ref R33, ref colour, ref notes, ref guid);
                        break;

                    case eFramePropType.DbChannel:
                        break;

                    case eFramePropType.SD:
                        break;

                    case eFramePropType.Variable:

                        if (!backlog.Contains(id))
                        {
                            // the sub sections need to exist to get their profiles
                            backlog.Add(id);
                            continue;
                        }
                        backlog.Remove(id);

                        int      numberItems = 0;
                        string[] startSec    = null;
                        string[] endSec      = null;
                        double[] myLength    = null;
                        int[]    myType      = null;
                        int[]    ei33        = null;
                        int[]    ei22        = null;

                        m_model.PropFrame.GetNonPrismatic(id, ref numberItems, ref startSec, ref endSec, ref myLength, ref myType, ref ei33, ref ei22, ref colour, ref notes, ref guid);

                        // Check type
                        if (myType.Any(x => x != 1))
                        {
                            Engine.Base.Compute.RecordWarning("BhoM can only pull Non-prismatic sections with relative length values.");
                            break;
                        }

                        // convert length values to relative positions between 0 and 1
                        List <double> positions = new List <double>()
                        {
                            0
                        };
                        for (int i = 0; i < myLength.Length; i++)
                        {
                            positions.Add(System.Convert.ToDouble(myLength[i]) + positions[i]);
                        }
                        double totLength = myLength.Sum();
                        positions = positions.Select(x => x / System.Convert.ToDouble(totLength)).ToList();

                        // Getting a Profile from a name in the propList
                        Func <string, IProfile> getProfile = sectionName =>
                        {
                            ISectionProperty sec = propList.First(x => x.DescriptionOrName() == sectionName);
                            if (sec is IGeometricalSection)
                            {
                                return((sec as IGeometricalSection).SectionProfile);
                            }
                            else
                            {
                                return(null);
                            }
                        };

                        // convert start/end section for each segment to a list of profiles (where each profile is both start and end for two segments)
                        List <IProfile> profiles = new List <IProfile>();
                        profiles.Add(getProfile(startSec.First()));
                        endSec.ToList().ForEach(x => profiles.Add(getProfile(x)));

                        // check that start/end section are equal
                        for (int i = numberItems - 1; i >= 1; i--)
                        {
                            if (startSec[i] != endSec[i - 1])
                            {
                                profiles.Insert(i + 1, getProfile(startSec[i]));
                                positions.Insert(i + 1, positions[i] + System.Convert.ToDouble(Tolerance.Distance));
                            }
                        }

                        // Find the material of all elements and create a singel one (or have warning)
                        foreach (string subSectionName in startSec.Concat(endSec))
                        {
                            ISectionProperty sec = propList.First(x => x.DescriptionOrName() == subSectionName);
                            if (materialName == "")
                            {
                                materialName = sec.Material.DescriptionOrName();
                            }
                            else if (materialName != sec.Material.DescriptionOrName())
                            {
                                materialName = "";
                                Engine.Base.Compute.RecordWarning("All sub-sections must have the same material.");
                                break;
                            }
                        }

                        //Etabs can only accept sections that vary linearly along it's length
                        List <int> interpolationOrder = Enumerable.Repeat(1, positions.Count - 1).ToList();

                        if (profiles.Any(x => x == null))
                        {
                            Engine.Base.Compute.RecordNote("Tapered profiles require the sub-profiles to be geometrically defined, they can not be any kind of explicit section.");
                        }
                        else
                        {
                            dimensions = Engine.Spatial.Create.TaperedProfile(positions, profiles, interpolationOrder);
                        }
                        break;

                    case eFramePropType.Joist:
                        break;

                    case eFramePropType.Bridge:
                        break;

                    case eFramePropType.Cold_C:
                        break;

                    case eFramePropType.Cold_2C:
                        break;

                    case eFramePropType.Cold_Z:
                        break;

                    case eFramePropType.Cold_L:
                        break;

                    case eFramePropType.Cold_2L:
                        break;

                    case eFramePropType.Cold_Hat:
                        break;

                    case eFramePropType.BuiltupICoverplate:
                        break;

                    case eFramePropType.PCCGirderI:
                        break;

                    case eFramePropType.PCCGirderU:
                        break;

                    case eFramePropType.BuiltupIHybrid:
                        break;

                    case eFramePropType.BuiltupUHybrid:
                        break;

                    case eFramePropType.Concrete_L:
                        m_model.PropFrame.GetConcreteL(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref twt, ref horFlip, ref verticalFlip, ref colour, ref notes, ref guid);
                        dimensions = Engine.Spatial.Create.AngleProfile(t3, t2, tw, tf, 0, 0, horFlip, verticalFlip);
                        break;

                    case eFramePropType.FilledTube:
                        break;

                    case eFramePropType.FilledPipe:
                        break;

                    case eFramePropType.EncasedRectangle:
                        break;

                    case eFramePropType.EncasedCircle:
                        break;

                    case eFramePropType.BucklingRestrainedBrace:
                        break;

                    case eFramePropType.CoreBrace_BRB:
                        break;

                    case eFramePropType.ConcreteTee:
                        m_model.PropFrame.GetConcreteTee(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref twt, ref verticalFlip, ref colour, ref notes, ref guid);
                        dimensions = Engine.Spatial.Create.TSectionProfile(t3, t2, tw, tf, 0, 0, verticalFlip);
                        break;

                    case eFramePropType.ConcreteBox:
                        m_model.PropFrame.GetTube(id, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref colour, ref notes, ref guid);
                        if (tf == tw)
                        {
                            dimensions = Engine.Spatial.Create.BoxProfile(t3, t2, tf, 0, 0);
                        }
                        else
                        {
                            dimensions = Engine.Spatial.Create.FabricatedBoxProfile(t3, t2, tw, tf, tf, 0);
                        }
                        break;

                    case eFramePropType.ConcretePipe:
                        m_model.PropFrame.GetPipe(id, ref fileName, ref materialName, ref t3, ref tw, ref colour, ref notes, ref guid);
                        dimensions = Engine.Spatial.Create.TubeProfile(t3, tw);
                        break;

                    case eFramePropType.ConcreteCross:
                        break;

                    case eFramePropType.SteelPlate:
                        m_model.PropFrame.GetPlate(id, ref fileName, ref materialName, ref t3, ref t2, ref colour, ref notes, ref guid);
                        dimensions = Engine.Spatial.Create.RectangleProfile(t3, t2, 0);
                        break;

                    case eFramePropType.SteelRod:
                        m_model.PropFrame.GetRod(id, ref fileName, ref materialName, ref t3, ref colour, ref notes, ref guid);
                        dimensions = Engine.Spatial.Create.CircleProfile(t3);
                        break;

                    default:
                        break;
                    }
                    if (dimensions == null)
                    {
                        Engine.Base.Compute.RecordNote(propertyType.ToString() + " properties are not implemented in ETABS adapter. An empty section has been returned.");
                        constructSelector = "explicit";
                    }
                    #endregion


                    IMaterialFragment material;

                    if (!bhomMaterials.TryGetValue(materialName, out material))
                    {
                        material = new GenericIsotropicMaterial()
                        {
                            Name = materialName
                        };
                        Engine.Base.Compute.RecordNote("Could not get material from ETABS. GenericIsotropic material with 0 values have been extracted in its place.");
                    }

                    switch (constructSelector)
                    {
                    case "fromDimensions":
                        bhSectionProperty = Engine.Structure.Create.SectionPropertyFromProfile(dimensions, material, id);
                        break;

                    case "explicit":
                        bhSectionProperty = new ExplicitSection()
                        {
                            Area = Area,
                            Asy  = As2,
                            Asz  = As3,
                            Iy   = I22,
                            Iz   = I33,
                            J    = Torsion,
                            Rgy  = R22,
                            Rgz  = R33,
                            Wply = S22,    //capacity - plastic (wply)
                            Wplz = S33,
                            Wely = Z22,    //capacity elastic
                            Welz = Z33
                        };
                        bhSectionProperty.Material = material;
                        bhSectionProperty.Name     = id;

                        break;

                    default:
                        continue;
                    }
                    SetAdapterId(bhSectionProperty, id);

                    double[] modifiers = null;
                    if (m_model.PropFrame.GetModifiers(id, ref modifiers) == 0 && modifiers != null && modifiers.Length > 6 && modifiers.Any(x => x != 1))
                    {
                        SectionModifier modifier = new SectionModifier
                        {
                            Area = modifiers[0],
                            Asz  = modifiers[1],
                            Asy  = modifiers[2],
                            J    = modifiers[3],
                            Iz   = modifiers[4],
                            Iy   = modifiers[5]
                        };
                        bhSectionProperty.Fragments.Add(modifier);
                    }

                    propList.Add(bhSectionProperty);
                }
                ids = new List <string>(backlog);
            } while (backlog.Count > 0);

            return(propList);
        }
예제 #8
0
        public static ISectionProperty GetSectionProperty(cSapModel model, string propertyName, eFramePropType propertyType)
        {
            //if (modelData.sectionDict.ContainsKey(propertyName))
            //    return modelData.sectionDict[propertyName];

            ISectionProperty bhSectionProperty = null;
            IProfile         dimensions        = null;
            string           materialName      = "";

            string fileName = "";
            double t3       = 0;
            double t2       = 0;
            double tf       = 0;
            double tw       = 0;
            double twt      = 0;
            double tfb      = 0;
            double t2b      = 0;
            int    colour   = 0;
            string notes    = "";
            string guid     = "";

            bool verticalFlip = false;
            bool horFlip      = false;

            double Area, As2, As3, Torsion, I22, I33, S22, S33, Z22, Z33, R22, R33;

            Area = As2 = As3 = Torsion = I22 = I33 = S22 = S33 = Z22 = Z33 = R22 = R33 = 0;

            string constructSelector = "fromDimensions";


            #region long switch on section property type
            switch (propertyType)
            {
            case eFramePropType.I:
                model.PropFrame.GetISection(propertyName, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref t2b, ref tfb, ref colour, ref notes, ref guid);
                if (t2 == t2b)
                {
                    dimensions = Engine.Geometry.Create.ISectionProfile(t3, t2, tw, tf, 0, 0);
                }
                else
                {
                    dimensions = Engine.Geometry.Create.FabricatedISectionProfile(t3, t2, t2b, tw, tf, tfb, 0);
                }
                break;

            case eFramePropType.Channel:
                model.PropFrame.GetChannel(propertyName, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref colour, ref notes, ref guid);
                dimensions = Engine.Geometry.Create.ChannelProfile(t3, t2, tw, tf, 0, 0);
                break;

            case eFramePropType.T:
                break;

            case eFramePropType.Angle:
                model.PropFrame.GetAngle(propertyName, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref colour, ref notes, ref guid);
                dimensions = Engine.Geometry.Create.AngleProfile(t3, t2, tw, tf, 0, 0);
                break;

            case eFramePropType.DblAngle:
                break;

            case eFramePropType.Box:
                model.PropFrame.GetTube(propertyName, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref colour, ref notes, ref guid);
                if (tf == tw)
                {
                    dimensions = Engine.Geometry.Create.BoxProfile(t3, t2, tf, 0, 0);
                }
                else
                {
                    dimensions = Engine.Geometry.Create.FabricatedBoxProfile(t3, t2, tw, tf, tf, 0);
                }
                break;

            case eFramePropType.Pipe:
                model.PropFrame.GetPipe(propertyName, ref fileName, ref materialName, ref t3, ref tw, ref colour, ref notes, ref guid);
                dimensions = Engine.Geometry.Create.TubeProfile(t3, tw);
                break;

            case eFramePropType.Rectangular:
                model.PropFrame.GetRectangle(propertyName, ref fileName, ref materialName, ref t3, ref t2, ref colour, ref notes, ref guid);
                dimensions = Engine.Geometry.Create.RectangleProfile(t3, t2, 0);
                break;

            case eFramePropType.Auto:    //not member will have this assigned but it still exists in the propertyType list
                dimensions = Engine.Geometry.Create.CircleProfile(0.2);
                break;

            case eFramePropType.Circle:
                model.PropFrame.GetCircle(propertyName, ref fileName, ref materialName, ref t3, ref colour, ref notes, ref guid);
                dimensions = Engine.Geometry.Create.CircleProfile(t3);
                break;

            case eFramePropType.General:
                constructSelector = "explicit";
                model.PropFrame.GetGeneral(propertyName, ref fileName, ref materialName, ref t3, ref t2, ref Area, ref As2, ref As3, ref Torsion, ref I22, ref I33, ref S22, ref S33, ref Z22, ref Z33, ref R22, ref R33, ref colour, ref notes, ref guid);
                break;

            case eFramePropType.DbChannel:
                break;

            case eFramePropType.SD:
                break;

            case eFramePropType.Variable:
                break;

            case eFramePropType.Joist:
                break;

            case eFramePropType.Bridge:
                break;

            case eFramePropType.Cold_C:
                break;

            case eFramePropType.Cold_2C:
                break;

            case eFramePropType.Cold_Z:
                break;

            case eFramePropType.Cold_L:
                break;

            case eFramePropType.Cold_2L:
                break;

            case eFramePropType.Cold_Hat:
                break;

            case eFramePropType.BuiltupICoverplate:
                break;

            case eFramePropType.PCCGirderI:
                break;

            case eFramePropType.PCCGirderU:
                break;

            case eFramePropType.BuiltupIHybrid:
                break;

            case eFramePropType.BuiltupUHybrid:
                break;

            case eFramePropType.Concrete_L:
                model.PropFrame.GetConcreteL(propertyName, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref twt, ref horFlip, ref verticalFlip, ref colour, ref notes, ref guid);
                dimensions = Engine.Geometry.Create.AngleProfile(t3, t2, tw, tf, 0, 0, horFlip, verticalFlip);
                break;

            case eFramePropType.FilledTube:
                break;

            case eFramePropType.FilledPipe:
                break;

            case eFramePropType.EncasedRectangle:
                break;

            case eFramePropType.EncasedCircle:
                break;

            case eFramePropType.BucklingRestrainedBrace:
                break;

            case eFramePropType.CoreBrace_BRB:
                break;

            case eFramePropType.ConcreteTee:
                model.PropFrame.GetConcreteTee(propertyName, ref fileName, ref materialName, ref t3, ref t2, ref tf, ref tw, ref twt, ref verticalFlip, ref colour, ref notes, ref guid);
                dimensions = Engine.Geometry.Create.TSectionProfile(t2, t2, tw, tf, 0, 0, verticalFlip);
                break;

            case eFramePropType.ConcreteBox:
                break;

            case eFramePropType.ConcretePipe:
                break;

            case eFramePropType.ConcreteCross:
                break;

            case eFramePropType.SteelPlate:
                break;

            case eFramePropType.SteelRod:
                break;

            default:
                throw new NotImplementedException("Section convertion for the type: " + propertyType.ToString() + " is not implemented in ETABS adapter");
            }
            if (dimensions == null)
            {
                throw new NotImplementedException("Section convertion for the type: " + propertyType.ToString() + " is not implemented in ETABS adapter");
            }
            #endregion


            IMaterialFragment material;
            if (materialName == "")
            {
                material = Engine.Structure.Create.Steel("Steel");
            }
            else
            {
                material = GetMaterial(model, materialName);
            }


            switch (constructSelector)
            {
            case "fromDimensions":
                if (material is Steel || material is Aluminium)
                {
                    bhSectionProperty = Create.SteelSectionFromProfile(dimensions);
                }
                else if (material is Concrete)
                {
                    bhSectionProperty = Create.ConcreteSectionFromProfile(dimensions);
                }
                else
                {
                    Engine.Reflection.Compute.RecordWarning("Reading sections of material type " + material.GetType().Name + "is not supported. Section with name " + propertyName + " was not pulled");
                    return(null);
                }

                break;

            case "explicit":
                ExplicitSection eSection = new ExplicitSection();
                eSection.Area = Area;
                eSection.Asy  = As2;
                eSection.Asz  = As3;
                //eSection.CentreY = ;
                //eSection.CentreZ = ;
                //eSection.Iw = 0;//warping
                eSection.Iy   = I22;
                eSection.Iz   = I33;
                eSection.J    = Torsion;
                eSection.Rgy  = R22;
                eSection.Rgz  = R33;
                eSection.Wply = S22;    //capacity - plastic (wply)
                eSection.Wplz = S33;
                //eSection.Vpy = 0;
                //eSection.Vpz = 0;
                //eSection.Vy = 0;
                //eSection.Vz = 0;
                eSection.Wely = Z22;    //capacity elastic
                eSection.Welz = Z33;
                break;

            default:
                break;
            }

            bhSectionProperty.Material = material;
            bhSectionProperty.Name     = propertyName;
            bhSectionProperty.CustomData.Add(AdapterId, propertyName);
            //modelData.sectionDict.Add(propertyName, bhSectionProperty);

            return(bhSectionProperty);
        }
예제 #9
0
        /***************************************************/

        private List <Bar> ReadBars(List <string> ids = null)
        {
            List <Bar> barList   = new List <Bar>();
            int        nameCount = 0;

            string[] names = { };

            if (ids == null)
            {
                m_model.FrameObj.GetNameList(ref nameCount, ref names);
                ids = names.ToList();
            }

            //Storing the sectionproperties as they are being pulled out, to only pull each section once.
            Dictionary <string, ISectionProperty> sectionProperties = new Dictionary <string, ISectionProperty>();

            foreach (string id in ids)
            {
                try
                {
                    Bar bhBar = new Bar();
                    bhBar.CustomData.Add(AdapterId, id);
                    string startId = "";
                    string endId   = "";
                    m_model.FrameObj.GetPoints(id, ref startId, ref endId);

                    List <Node> endNodes = ReadNodes(new List <string> {
                        startId, endId
                    });
                    bhBar.StartNode = endNodes[0];
                    bhBar.EndNode   = endNodes[1];

                    bool[]   restraintStart = new bool[6];
                    double[] springStart    = new double[6];
                    bool[]   restraintEnd   = new bool[6];
                    double[] springEnd      = new double[6];

                    m_model.FrameObj.GetReleases(id, ref restraintStart, ref restraintEnd, ref springStart, ref springEnd);
                    bhBar.Release = new BarRelease();
                    bhBar.Release.StartRelease = Helper.GetConstraint6DOF(restraintStart, springStart);
                    bhBar.Release.EndRelease   = Helper.GetConstraint6DOF(restraintEnd, springEnd);

                    eFramePropType propertyType = eFramePropType.General;
                    string         propertyName = "";
                    string         sAuto        = "";
                    m_model.FrameObj.GetSection(id, ref propertyName, ref sAuto);
                    if (propertyName != "None")
                    {
                        ISectionProperty property;

                        //Check if section allready has been pulled once
                        if (!sectionProperties.TryGetValue(propertyName, out property))
                        {
                            //if not pull it and store it
                            m_model.PropFrame.GetTypeOAPI(propertyName, ref propertyType);
                            property = Helper.GetSectionProperty(m_model, propertyName, propertyType);
                            sectionProperties[propertyName] = property;
                        }

                        bhBar.SectionProperty = property;
                    }

                    bool   autoOffset  = false;
                    double startLength = 0;
                    double endLength   = 0;
                    double rz          = 0;
                    m_model.FrameObj.GetEndLengthOffset(id, ref autoOffset, ref startLength, ref endLength, ref rz);
                    if (!autoOffset)
                    {
                        bhBar.Offset       = new oM.Structure.Offsets.Offset();
                        bhBar.Offset.Start = startLength == 0 ? null : new Vector()
                        {
                            X = startLength * (-1), Y = 0, Z = 0
                        };
                        bhBar.Offset.End = endLength == 0 ? null : new Vector()
                        {
                            X = endLength, Y = 0, Z = 0
                        };
                    }
                    else if (rz > 0)
                    {
                        bhBar = bhBar.SetAutoLengthOffset(autoOffset, rz);
                    }

                    barList.Add(bhBar);
                }
                catch
                {
                    BH.Engine.Reflection.Compute.RecordError("Bar " + id.ToString() + " could not be pulled");
                }
            }
            return(barList);
        }