Exemple #1
0
        /// <summary>
        /// Create a new (or update an existing) section family in the model
        /// </summary>
        /// <param name="profile">The section profile to assign to the new property.</param>
        /// <param name="exInfo">Optional.  The execution information of the current action.
        /// If an object has been created previously with matching execution information then
        /// instead of creating a new item this previous one will be updated and returned instead.
        /// This enables this method to be used parametrically.</param>
        /// <returns>The created or updated section family</returns>
        public SectionFamily SectionFamily(SectionProfile profile, ExecutionInfo exInfo = null)
        {
            SectionFamily result = new SectionFamily();

            result         = Model.History.Update(exInfo, result);
            result.Profile = profile;
            if (result.Name == null)
            {
                result.Name = Model.Families.NextAvailableName("Section", result, true);
            }
            Model.Add(result);
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Change the type of profile of this section, copying across as much data as possible
        /// </summary>
        /// <typeparam name="TProfile">The type of the new profile</typeparam>
        /// <returns>The </returns>
        public TProfile ChangeProfileType <TProfile>() where TProfile : SectionProfile, new()
        {
            SectionProfile oldProfile = Profile;
            TProfile       newProfile = new TProfile();

            if (oldProfile != null)
            {
                newProfile.CopyFieldsFrom(oldProfile);
            }
            newProfile.CatalogueName = null;
            Profile = newProfile;
            return(newProfile);
        }
Exemple #3
0
        /// Get the total cross-sectional area of a specified material within this section.
        /// If no material is specified, will return the total cross-sectional area regardless
        /// of material.
        /// </summary>
        /// <param name="material">The material to calculate the cross-sectional area of</param>
        /// <returns></returns>
        public double GetArea(Material material = null)
        {
            double result = 0;
            SectionProfileCollection profiles = Profiles;

            for (int i = 0; i < profiles.Count; i++)
            {
                SectionProfile profile = profiles[i];
                if (material == null || profile.Material == material)
                {
                    result += profile.Area;
                }
                // TODO: Subtract area of embedded sections & reinforcement
            }
            return(result);
        }
Exemple #4
0
        /// <summary>
        /// Change the type of profile of this section, copying across as much data as possible
        /// </summary>
        /// <param name="newType">The type of the new profile.  Must be a non-abstract subtype of SectionProfile</param>
        /// <returns></returns>
        public SectionProfile ChangeProfieType(Type newType)
        {
            SectionProfile oldProfile = Profile;
            Assembly       assembly   = Assembly.Load(newType.Assembly.FullName);
            SectionProfile newProfile = assembly.CreateInstance(newType.FullName) as SectionProfile;

            if (newProfile != null)
            {
                if (oldProfile != null)
                {
                    newProfile.CopyPropertiesFrom(oldProfile);
                }
                newProfile.CatalogueName = null;
                Profile = newProfile;
            }
            return(newProfile);
        }
Exemple #5
0
        /// <summary>
        /// Create a new SectionProfile based on a string description.
        /// </summary>
        /// <param name="description"></param>
        /// <param name="catalogue"></param>
        /// <returns></returns>
        public static SectionProfile FromDescription(string description, SectionProfileLibrary catalogue = null)
        {
            if (catalogue != null)
            {
                // Check in catalogue:
                SectionProfile profile = catalogue.GetByCatalogueName(description);
                if (profile != null)
                {
                    return(profile.Duplicate());
                }
            }

            string[] tokens = description.Split(' ');
            if (tokens.Length > 1)
            {
                switch (tokens[0].Trim().ToUpper())
                {
                case "I":
                    return(new SymmetricIProfile(tokens[1]));

                case "T":
                    return(new TProfile(tokens[1]));

                case "A":
                    return(new AngleProfile(tokens[1]));

                case "CIRC":
                    return(new CircularProfile(tokens[1]));

                case "CHS":
                    return(new CircularHollowProfile(tokens[1]));

                case "RECT":
                    return(new RectangularProfile(tokens[1]));

                case "RHS":
                    return(new RectangularProfile(tokens[1]));
                }
                throw new NotImplementedException("The specified section profile description could not be parsed successfully."); //If we're here, we haven't caught the case
            }

            return(null);
        }
Exemple #6
0
 /// <summary>
 /// Notify this section that one of its constutuent profiles has been modified
 /// </summary>
 /// <param name="profile"></param>
 internal void NotifyProfileChanged(SectionProfile profile)
 {
     NotifyPropertyChanged("Profile");
     NotifyPropertyChanged("Profiles");
 }
Exemple #7
0
 /// <summary>
 /// Initialises a section property with the given name and profile
 /// </summary>
 /// <param name="name"></param>
 /// <param name="profile"></param>
 public SectionFamily(string name, SectionProfile profile)
 {
     Name    = name;
     Profile = profile;
 }
Exemple #8
0
 /// <summary>
 /// Initialises a section property with the given profile
 /// </summary>
 /// <param name="profile"></param>
 public SectionFamily(SectionProfile profile)
 {
     Profile = profile;
 }