Example #1
0
        /// <summary>
        /// This node can set the Section for Advance Steel beams from Dynamo.
        /// For the Section use the following format: "HEA  DIN18800-1#@§@#HEA100"
        /// </summary>
        /// <param name="beamElement">Advance Steel beam</param>
        /// <param name="sectionName">Section</param>
        /// <returns></returns>
        public static void SetSection(AdvanceSteel.Nodes.Object beamElement, string sectionName)
        {
            //lock the document and start transaction
            using (var _CADAccess = new AdvanceSteel.Services.ObjectAccess.CADContext())
            {
                string handle = beamElement.Handle;

                FilerObject obj = Utils.GetObject(handle);

                if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kBeam))
                {
                    string sectionType = string.Empty;
                    string sectionSize = string.Empty;

                    string   separator = "#@" + '§' + "@#";
                    string[] section   = sectionName.Split(new string[] { separator }, System.StringSplitOptions.None);

                    if (section.Length == 2)
                    {
                        sectionType = section[0];
                        sectionSize = section[1];
                    }

                    Beam beam = obj as Beam;
                    beam.ChangeProfile(sectionType, sectionSize);
                }

                else
                {
                    throw new System.Exception("Failed to change section");
                }
            }
        }
Example #2
0
        /// <summary>
        /// This node can set the Section for Advance Steel beams from Dynamo.
        /// For the Section use the following format: "HEA  DIN18800-1#@§@#HEA100"
        /// </summary>
        /// <param name="beamElement">Advance Steel beam</param>
        /// <param name="sectionName">Section</param>
        /// <returns></returns>
        public static void SetSection(AdvanceSteel.Nodes.Object beamElement, string sectionName)
        {
            //lock the document and start transaction
            using (var _CADAccess = new AdvanceSteel.Services.ObjectAccess.CADContext())
            {
                string handle = beamElement.Handle;

                FilerObject obj = Utils.GetObject(handle);

                if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kBeam))
                {
                    string sectionType = Utils.SplitSectionName(sectionName)[0];
                    string sectionSize = Utils.SplitSectionName(sectionName)[1];

                    Beam beam = obj as Beam;
                    if (obj.IsKindOf(FilerObject.eObjectType.kCompoundBeam) && !Utils.CompareCompoundSectionTypes(beam.ProfSectionType, sectionType))
                    {
                        throw new System.Exception("Failed to change section as compound section type is different");
                    }
                    beam.ChangeProfile(sectionType, sectionSize);
                }
                else
                {
                    throw new System.Exception("Failed to change section");
                }
            }
        }
        /// <summary>
        /// This node can set User attributes for Advance Steel elements from Dynamo
        /// </summary>
        /// <param name="element">Advance Steel element</param>
        /// <param name="AttIdx">The index of the User attribute. Is a number between 1 and 10</param>
        /// <param name="value">Attribute value</param>
        /// <returns></returns>
        public static void SetUserAttribute(AdvanceSteel.Nodes.Object element, int AttIdx, string value)
        {
            if (AttIdx < 1 || AttIdx > 10)
            {
                throw new System.Exception("Attribute index is not in the range from 1 to 10");
            }

            //lock the document and start transaction
            using (var _CADAccess = new AdvanceSteel.Services.ObjectAccess.CADContext())
            {
                string handle = element.Handle;

                FilerObject   obj    = Utils.GetObject(handle);
                AtomicElement atomic = obj as AtomicElement;

                if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kAtomicElem))
                {
                    //[1, 10] ->[0 ,9]
                    AttIdx = AttIdx - 1;

                    atomic.SetUserAttribute(AttIdx, value);
                }
                else
                {
                    throw new System.Exception("Failed to set attribute");
                }
            }
        }
        /// <summary>
        /// This node can set the Material for Advance Steel elements from Dynamo
        /// </summary>
        /// <param name="element">Advance Steel element</param>
        /// <param name="materialName">Material</param>
        /// <returns></returns>
        public static void SetMaterial(AdvanceSteel.Nodes.Object element, string materialName)
        {
            //lock the document and start transaction
            using (var _CADAccess = new AdvanceSteel.Services.ObjectAccess.CADContext())
            {
                string handle = element.Handle;

                FilerObject   obj    = Utils.GetObject(handle);
                AtomicElement atomic = obj as AtomicElement;

                if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kAtomicElem))
                {
                    atomic.Material = materialName;
                }

                else
                {
                    throw new System.Exception("Failed to set material");
                }
            }
        }