Exemplo n.º 1
0
        private void CreateNewTagForPointLoad(View activeV, XYZ loadPosition, PointLoad pl)
        {
            Transaction t = new Transaction(_doc);

            t.Start("Create tag for point load");
            TagMode        tagMode = TagMode.TM_ADDBY_CATEGORY;
            TagOrientation tagorn  = TagOrientation.Horizontal;

            IndependentTag tag     = IndependentTag.Create(_doc, activeV.Id, new Reference(pl), false, tagMode, tagorn, loadPosition);
            FamilySymbol   tagType =
                (from fs in new FilteredElementCollector(_doc)
                 .OfCategory(BuiltInCategory.OST_PointLoadTags)
                 .OfClass(typeof(FamilySymbol))
                 .Cast <FamilySymbol>()
                 where fs.Name.Equals(Default.TYPE_NAME_POINT_LOAD)
                 select fs)
                .FirstOrDefault();

            if (tagType != null)
            {
                tag.ChangeTypeId(tagType.Id);
            }
            t.Commit();
            AssociateTagToPointLoad(pl, tag);
        }
Exemplo n.º 2
0
        private void AssociateTagToPointLoad(PointLoad pl, IndependentTag tag)
        {
            using (Transaction trans = new Transaction(_doc, "Create Extensible Store"))
            {
                trans.Start();

                SchemaBuilder builder = new SchemaBuilder(Guids.POINTLOAD_SHEMA_GUID);

                builder.SetReadAccessLevel(AccessLevel.Public);
                builder.SetWriteAccessLevel(AccessLevel.Public);

                builder.SetSchemaName("Tag");

                builder.SetDocumentation("The tag linked to the point load");

                // Create field1
                FieldBuilder fieldBuilder1 = builder.AddSimpleField("Tag", typeof(ElementId));

                // Register the schema object
                Schema schema = builder.Finish();

                Field  tagField = schema.GetField("Tag");
                Entity ent      = new Entity(schema);

                ent.Set(tagField, tag.Id);
                pl.SetEntity(ent);

                trans.Commit();
            }
        }
Exemplo n.º 3
0
        /***************************************************/

        private bool CreateLoad(PointLoad bhLoad)
        {
            List <Node> nodes   = bhLoad.Objects.Elements.ToList();
            string      loadPat = GetAdapterId <string>(bhLoad.Loadcase);
            string      cSys    = bhLoad.Axis.ToCSI();

            double[] val =
            {
                bhLoad.Force.X,
                bhLoad.Force.Y,
                bhLoad.Force.Z,
                bhLoad.Moment.X,
                bhLoad.Moment.Y,
                bhLoad.Moment.Z,
            };

            bool replace = SAPPushConfig.ReplaceLoads;

            foreach (Node bhNode in nodes)
            {
                if (m_model.PointObj.SetLoadForce(GetAdapterId <string>(bhNode), loadPat, ref val, replace, cSys, eItemType.Objects) != 0)
                {
                    CreateElementError("Point Load", bhLoad.Name);
                }
            }

            SetAdapterId(bhLoad, null);

            return(true);
        }
Exemplo n.º 4
0
        /***************************************************/

        private List <ILoad> ReadPointLoad(List <Loadcase> loadcases)
        {
            List <ILoad> bhLoads = new List <ILoad>();

            Dictionary <string, Node> bhomNodes = ReadNode().ToDictionary(x => GetAdapterId <string>(x));

            string[] names     = null;
            string[] loadcase  = null;
            string[] CSys      = null;
            int[]    step      = null;
            int      nameCount = 0;

            double[] fx = null;
            double[] fy = null;
            double[] fz = null;
            double[] mx = null;
            double[] my = null;
            double[] mz = null;

            if (m_model.PointObj.GetLoadForce("All", ref nameCount, ref names, ref loadcase, ref step, ref CSys, ref fx, ref fy, ref fz, ref mx, ref my, ref mz, eItemType.Group) != 0)
            {
                return(bhLoads);
            }

            for (int i = 0; i < nameCount; i++)
            {
                if (CSys[i] != "Global")
                {
                    Engine.Base.Compute.RecordWarning($"The coordinate system: {CSys[i]} was not read. The PointLoads defined in the coordinate system: {CSys[i]} were set as Global");
                }

                Loadcase bhLoadcase = loadcases.FirstOrDefault(x => x.Name == loadcase[i]);

                if (bhLoadcase == null)
                {
                    continue;
                }

                PointLoad bhLoad = new PointLoad()
                {
                    Force = new Vector()
                    {
                        X = fx[i], Y = fy[i], Z = fz[i]
                    },
                    Moment = new Vector()
                    {
                        X = mx[i], Y = my[i], Z = mz[i]
                    },
                    Loadcase = bhLoadcase,
                    Objects  = new BHoMGroup <Node>()
                    {
                        Elements = { bhomNodes[names[i]] }
                    }
                };

                bhLoads.Add(bhLoad);
            }

            return(bhLoads);
        }
Exemplo n.º 5
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFLoadingConcentrated CreateConcentratedLoad(PointLoad pointLoad, object[] lusasPoints)
        {
            IFLoadingConcentrated lusasPointLoad;
            IFLoadcase            assignedLoadcase = (IFLoadcase)d_LusasData.getLoadset(pointLoad.Loadcase.AdapterId <int>(typeof(LusasId)));

            if (d_LusasData.existsAttribute("Loading", pointLoad.Name))
            {
                lusasPointLoad = (IFLoadingConcentrated)d_LusasData.getAttribute("Loading", pointLoad.Name);
            }
            else
            {
                lusasPointLoad = d_LusasData.createLoadingConcentrated(pointLoad.Name);
                lusasPointLoad.setConcentrated(
                    pointLoad.Force.X, pointLoad.Force.Y, pointLoad.Force.Z,
                    pointLoad.Moment.X, pointLoad.Moment.Y, pointLoad.Moment.Z);
            }

            IFAssignment lusasAssignment = m_LusasApplication.assignment();

            lusasAssignment.setLoadset(assignedLoadcase);
            lusasPointLoad.assignTo(lusasPoints, lusasAssignment);

            int adapterIdName = lusasPointLoad.getID();

            pointLoad.SetAdapterId(typeof(LusasId), adapterIdName);

            return(lusasPointLoad);
        }
Exemplo n.º 6
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private bool CreateObject(PointLoad pointLoad)
        {
            int err        = 0;
            int loadCaseId = GetAdapterId <int>(pointLoad);

            double[] forces  = new double[3];
            double[] moments = new double[3];
            forces[0]  = pointLoad.Force.X;
            forces[1]  = pointLoad.Force.Y;
            forces[2]  = pointLoad.Force.Z;
            moments[0] = pointLoad.Moment.X;
            moments[1] = pointLoad.Moment.Y;
            moments[2] = pointLoad.Moment.Z;
            foreach (Node node in pointLoad.Objects.Elements)
            {
                int nodeId = GetAdapterId <int>(node);
                err = St7.St7SetNodeForce3(1, nodeId, loadCaseId, forces);
                if (!St7ErrorCustom(err, "Couldn't set point load for a loadcase " + loadCaseId + " node " + nodeId))
                {
                    return(false);
                }
                err = St7.St7SetNodeMoment3(1, nodeId, loadCaseId, moments);
                if (!St7ErrorCustom(err, "Couldn't set point load for a loadcase " + loadCaseId + " node " + nodeId))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 7
0
        public void AssociateLoadToFoundation(FamilyInstance foundation, PointLoad pointLoad)
        {
            using (Transaction trans = new Transaction(_doc, "Create Extensible Store"))
            {
                trans.Start();

                SchemaBuilder builder = new SchemaBuilder(Guids.FOUNDATION_SHEMA_GUID);

                builder.SetReadAccessLevel(AccessLevel.Public);
                builder.SetWriteAccessLevel(AccessLevel.Public);

                builder.SetSchemaName("PointLoad");

                builder.SetDocumentation("The point load linked to the foundation");

                // Create field1
                FieldBuilder fieldBuilder1 = builder.AddSimpleField("PointLoad", typeof(ElementId));

                // Register the schema object
                Schema schema = builder.Finish();

                Field  pointLoadField = schema.GetField("PointLoad");
                Entity ent            = new Entity(schema);

                ent.Set(pointLoadField, pointLoad.Id);

                foundation.SetEntity(ent);

                trans.Commit();
            }
        }
Exemplo n.º 8
0
        public static List <ICurve> Visualize(this PointLoad pointForce, double scaleFactor = 1.0, bool displayForces = true, bool displayMoments = true, bool asResultants = true)
        {
            if (pointForce.IsNull())
            {
                return(null);
            }

            List <ICurve> arrows = new List <ICurve>();

            Vector forceVec  = pointForce.Force * scaleFactor;
            Vector momentVec = pointForce.Moment * scaleFactor;

            foreach (Node node in pointForce.Objects.Elements)
            {
                if (displayForces)
                {
                    arrows.AddRange(Arrows(node.Position, forceVec, true, asResultants));
                }
                if (displayMoments)
                {
                    arrows.AddRange(Arrows(node.Position, momentVec, false, asResultants));
                }
            }

            return(arrows);
        }
Exemplo n.º 9
0
 //Fill loads to nodal load component
 private static void fillComponent(ref NodalLoadComponent component, PointLoad kPLoad)
 {
     component.Force = new Point3D {
         X = kPLoad.force.X * 1000, Y = kPLoad.force.Y * 1000, Z = kPLoad.force.Z * 1000
     };
     component.Moment = new Point3D {
         X = kPLoad.moment.X * 1000, Y = kPLoad.moment.Y * 1000, Z = kPLoad.moment.Z * 1000
     };
 }
Exemplo n.º 10
0
        private PointLoad CreateNewLoadForFoundation(FamilyInstance foundation, XYZ loadPosition, XYZ force, XYZ moment)
        {
            PointLoad   pl;
            Transaction t = new Transaction(_doc);

            t.Start("Creat point load");
            pl = PointLoad.Create(_doc, loadPosition, force, moment, null, null);
            t.Commit();
            AssociateLoadToFoundation(foundation, pl);
            return(pl);
        }
Exemplo n.º 11
0
        public static void SetLoad(cSapModel model, PointLoad pointLoad, bool replace)
        {
            double[] pfValues = new double[] { pointLoad.Force.X, pointLoad.Force.Y, pointLoad.Force.Z, pointLoad.Moment.X, pointLoad.Moment.Y, pointLoad.Moment.Z };
            int      ret      = 0;

            foreach (Node node in pointLoad.Objects.Elements)
            {
                string csiCaseName = CaseNameToCSI(pointLoad.Loadcase);
                ret = model.PointObj.SetLoadForce(node.CustomData[AdapterId].ToString(), csiCaseName, ref pfValues, replace);
            }
        }
Exemplo n.º 12
0
        /***************************************************/

        public void SetLoad(PointLoad pointLoad, bool replace)
        {
            if (pointLoad.Axis != LoadAxis.Global)
            {
                Engine.Base.Compute.RecordWarning("The local coordinate system of BHoM nodes are not pushed to ETABS, Local Axis PointLoads are set on the Global Axis");
            }

            double[] pfValues = new double[] { pointLoad.Force.X, pointLoad.Force.Y, pointLoad.Force.Z, pointLoad.Moment.X, pointLoad.Moment.Y, pointLoad.Moment.Z };
            int      ret      = 0;

            foreach (Node node in pointLoad.Objects.Elements)
            {
                string caseName = GetAdapterId <string>(pointLoad.Loadcase);
                string nodeName = GetAdapterId <string>(node);
                ret = m_model.PointObj.SetLoadForce(nodeName, caseName, ref pfValues, replace);
            }
        }
Exemplo n.º 13
0
        public FactorPointLoadDialog(SlopeDefineCanvas canvas, PointLoad load)
        {
            InitializeComponent();

            this.canvas = canvas;
            this.load   = load;

            // get units dependent scaling factor and strings
            double factor;
            string coordUnits, loadUnits;

            switch (canvas.Units)
            {
            case Units.Metres: factor = 0.0254; coordUnits = "m"; loadUnits = "kN"; break;

            case Units.Millimetres: factor = 25.4; coordUnits = "mm"; loadUnits = "kN"; break;

            case Units.Feet: factor = 1.0 / 12.0; coordUnits = "ft"; loadUnits = "lbf"; break;

            default: factor = 1.0; coordUnits = "in"; loadUnits = "lbf"; break;
            }

            // set units labels
            nodeUnits.Content  = coordUnits;
            xLoadUnits.Content = loadUnits;
            yLoadUnits.Content = loadUnits;

            // set node coordinates
            double xCoord, yCoord;

            xCoord         = (load.Node.Point.X - canvas.OriginOffsetX) / canvas.DpiX * factor * canvas.Scale;
            yCoord         = (canvas.ActualHeight - load.Node.Point.Y - canvas.OriginOffsetY) / canvas.DpiY * factor * canvas.Scale;
            coords.Content = string.Format("({0}, {1})", Math.Round(xCoord, 2), Math.Round(yCoord, 2));

            // set existing load values (if present)
            MaterialBlock parent = canvas.Substructs.Find(delegate(MaterialBlock mb) { return(mb.Material.Name != "NULL" && mb.PointLoads.Contains(load)); });

            isLoadedX.IsEnabled = parent != null && load.IsLoadedX;
            isLoadedX.IsChecked = xFactor.IsEnabled = parent != null && load.IsActiveX;
            xFactor.Text        = string.Format("{0}", Math.Round(load.XFactor, 3));
            xLoad.Text          = string.Format("{0}", Math.Round(load.XLoad, 2));
            isLoadedY.IsEnabled = parent != null && load.IsLoadedY;
            isLoadedY.IsChecked = yFactor.IsEnabled = parent != null && load.IsActiveY;
            yFactor.Text        = string.Format("{0}", Math.Round(load.YFactor, 3));
            yLoad.Text          = string.Format("{0}", Math.Round(load.YLoad, 2));
        }
Exemplo n.º 14
0
        public AddPointLoadDialog(SlopeCanvas canvas, PointLoad load)
        {
            InitializeComponent();

            this.canvas = canvas;
            this.load   = load;

            // get units dependent scaling factor and strings
            double factor;
            string coordUnits, loadUnits;

            switch (canvas.Units)
            {
            case Units.Metres: factor = 0.0254; coordUnits = "m"; loadUnits = "kN"; break;

            case Units.Millimetres: factor = 25.4; coordUnits = "mm"; loadUnits = "kN"; break;

            case Units.Feet: factor = 1.0 / 12.0; coordUnits = "ft"; loadUnits = "lbf"; break;

            default: factor = 1.0; coordUnits = "in"; loadUnits = "lbf"; break;
            }

            // set units labels
            nodeUnits.Content  = coordUnits;
            xLoadUnits.Content = loadUnits;
            yLoadUnits.Content = loadUnits;

            // set node coordinates
            double xCoord, yCoord;

            xCoord         = (load.Node.Point.X - canvas.OriginOffsetX) / canvas.DpiX * factor * canvas.Scale;
            yCoord         = (canvas.ActualHeight - load.Node.Point.Y - canvas.OriginOffsetY) / canvas.DpiY * factor * canvas.Scale;
            coords.Content = string.Format("({0}, {1})", Math.Round(xCoord, 2), Math.Round(yCoord, 2));

            // set existing load values (if present)
            isLoadedX.IsChecked = xLoad.IsEnabled = load.IsLoadedX;
            xLoad.Text          = string.Format("{0}", Math.Round(load.XLoad, 2));
            isLoadedY.IsChecked = yLoad.IsEnabled = load.IsLoadedY;
            yLoad.Text          = string.Format("{0}", Math.Round(load.YLoad, 2));
        }
Exemplo n.º 15
0
        private List <ILoad> ReadPointLoad(List <Loadcase> loadcases)
        {
            int          err      = 0;
            List <ILoad> bhLoads  = new List <ILoad>();
            List <Node>  allNodes = ReadNodes();

            foreach (Loadcase ldcs in loadcases)
            {
                foreach (Node node in allNodes)
                {
                    int      nodeId = GetAdapterId <int>(node);
                    double[] forces = new double[3];
                    err = St7.St7GetNodeForce3(1, nodeId, GetAdapterId <int>(ldcs), forces);
                    double[] moments = new double[3];
                    err = St7.St7GetNodeMoment3(1, nodeId, GetAdapterId <int>(ldcs), moments);
                    if (!IsZeroSqLength(forces) || !IsZeroSqLength(moments))
                    {
                        PointLoad bhLoad = new PointLoad()
                        {
                            Force = new Vector()
                            {
                                X = forces[0], Y = forces[1], Z = forces[2]
                            },
                            Moment = new Vector()
                            {
                                X = moments[0], Y = moments[1], Z = moments[2]
                            },
                            Loadcase = ldcs,
                            Objects  = new BHoMGroup <Node>()
                            {
                                Elements = { node }
                            }
                        };
                        bhLoads.Add(bhLoad);
                    }
                }
            }
            return(bhLoads);
        }
Exemplo n.º 16
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <ILoad> ReadPointLoads(List <string> ids = null)
        {
            List <ILoad> pointLoads = new List <ILoad>();

            object[] lusasConcentratedLoads = d_LusasData.getAttributes("Concentrated Load");

            if (!(lusasConcentratedLoads.Count() == 0))
            {
                List <Node> nodesList           = ReadNodes();
                Dictionary <string, Node> nodes = nodesList.ToDictionary(
                    x => x.AdapterId <string>(typeof(LusasId)));

                List <IFLoadcase> allLoadcases = new List <IFLoadcase>();

                for (int i = 0; i < lusasConcentratedLoads.Count(); i++)
                {
                    IFLoading lusasConcentratedLoad = (IFLoading)lusasConcentratedLoads[i];

                    IEnumerable <IGrouping <string, IFAssignment> > groupedByLoadcases =
                        GetLoadAssignments(lusasConcentratedLoad);

                    foreach (IEnumerable <IFAssignment> groupedAssignment in groupedByLoadcases)
                    {
                        PointLoad pointLoad = Adapters.Lusas.Convert.ToPointLoad(
                            lusasConcentratedLoad, groupedAssignment, nodes
                            );
                        List <string> analysisName = new List <string> {
                            lusasConcentratedLoad.getAttributeType()
                        };
                        pointLoad.Tags = new HashSet <string>(analysisName);
                        pointLoads.Add(pointLoad);
                    }
                }
            }

            return(pointLoads);
        }
Exemplo n.º 17
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static PointLoad ToPointLoad(
            IFLoading lusasPointLoad, IEnumerable <IFAssignment> lusasAssignments,
            Dictionary <string, Node> nodes)
        {
            IFLoadcase assignedLoadcase = (IFLoadcase)lusasAssignments.First().getAssignmentLoadset();
            Loadcase   loadcase         = ToLoadcase(assignedLoadcase);

            IEnumerable <Node> assignedNodes = GetPointAssignments(lusasAssignments, nodes);

            Vector forceVector = new Vector
            {
                X = lusasPointLoad.getValue("px"),
                Y = lusasPointLoad.getValue("py"),
                Z = lusasPointLoad.getValue("pz")
            };

            Vector momentVector = new Vector
            {
                X = lusasPointLoad.getValue("mx"),
                Y = lusasPointLoad.getValue("my"),
                Z = lusasPointLoad.getValue("mz")
            };

            PointLoad pointLoad = Engine.Structure.Create.PointLoad(
                loadcase,
                assignedNodes,
                forceVector,
                momentVector,
                LoadAxis.Global,
                GetName(lusasPointLoad));

            int adapterNameId = lusasPointLoad.getID();

            pointLoad.SetAdapterId(typeof(LusasId), adapterNameId);

            return(pointLoad);
        }
Exemplo n.º 18
0
        internal (Vector <double> loadJoints, Matrix <double> loadMagnitude) BuildLoadStructures(IEnumerable <Point3d> joints)
        {
            // TODO : It is assumed one load per joint, correct this
            Vector <double> loadJoints = Vector <double> .Build.Dense(Loads.Count);

            Matrix <double> loadMagnitude = Matrix <double> .Build.Dense(Loads.Count, 2);

            for (int i = 0; i < Loads.Count; i++)
            {
                PointLoad load = Loads.ElementAt(i);

                int?loadNode = GetJoint(load.Location, joints);
                if (!loadNode.HasValue)
                {
                    throw new InvalidOperationException("Load is not at a joint node");
                }

                loadJoints[i]       = loadNode.Value;
                loadMagnitude[i, 0] = load.XForce;
                loadMagnitude[i, 1] = load.YForce;
            }

            return(loadJoints, loadMagnitude);
        }
Exemplo n.º 19
0
 public static LoadType LoadType(this PointLoad load)
 {
     return(oM.Structure.Loads.LoadType.PointForce);
 }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
        public static void Edof_BC_fext(out Matrix <double> Edof, out Vector <double> BC, out Vector <double> Fext, out Vector <double> pres, out Matrix <double> bcSprings, List <Bar> bars, List <Node> constraints, List <PointLoad> loads, List <BarPrestressLoad> ploads)
        {
            int nEL   = bars.Count;
            int nNode = constraints.Count;

            List <int>   dofs     = new List <int>();
            List <Point> elPoints = new List <Point>();

            for (int i = 0; i < nEL; i++)
            {
                Bar aBar = bars[i];
                elPoints.Add(aBar.StartNode.Position);
                elPoints.Add(aBar.EndNode.Position);
            }

            double tol = 1e-5;

            List <Point> cullDup = Geometry.Compute.CullDuplicates(elPoints, tol);

            Matrix <double> nodeDofs = DenseMatrix.Create(cullDup.Count, 3, 0);

            for (int i = 0; i < cullDup.Count; i++)
            {
                Vector <double> nodeDof = DenseVector.Create(3, 0);
                nodeDof[0] = 3 * i + 1;
                nodeDof[1] = 3 * i + 2;
                nodeDof[2] = 3 * i + 3;

                nodeDofs.SetRow(i, nodeDof);
            }


            // create edof
            Vector <double> e    = DenseVector.Create(nEL, 0);
            Matrix <double> edof = DenseMatrix.Create(nEL, 6, 0);

            for (int i = 0; i < nEL; i++)
            {
                Bar aBar = bars[i];

                int indStart = cullDup.IndexOf(Geometry.Query.ClosestPoint(aBar.StartNode.Position, cullDup));
                int indEnd   = cullDup.IndexOf(Geometry.Query.ClosestPoint(aBar.EndNode.Position, cullDup));
                dofs.Add(indStart);

                e[i] = i + 1;

                edof.SetRow(i, nodeDofs.Row(indStart).ToColumnMatrix().Stack(nodeDofs.Row(indEnd).ToColumnMatrix()).Column(0));

                //test of indexing
                string id = "FEMID: " + i.ToString();
                bars[i].Tags.Add(id);
            }

            Vector <double> nDof         = DenseVector.Create(1, 0);
            Vector <double> temp         = DenseVector.Create(2, 0);
            Matrix <double> bc           = DenseMatrix.Create(1, 1, 0);
            Matrix <double> bc_stiffness = DenseMatrix.Create(1, 2, 0);

            for (int i = 0; i < constraints.Count; i++)
            {
                Node aNode = constraints[i];

                int nodeIndex = cullDup.IndexOf(Geometry.Query.ClosestPoint(aNode.Position, cullDup));

                // Fixed
                if (aNode.Support.TranslationX.Equals(BH.oM.Structure.Constraints.DOFType.Fixed))
                {
                    nDof[0] = nodeDofs.Row(nodeIndex).At(0);
                    int index = bc.Column(0).Count;
                    bc = bc.InsertRow(index, nDof);
                }
                if (aNode.Support.TranslationY.Equals(BH.oM.Structure.Constraints.DOFType.Fixed))
                {
                    nDof[0] = nodeDofs.Row(nodeIndex).At(1);
                    int index = bc.Column(0).Count;
                    bc = bc.InsertRow(index, nDof);
                }
                if (aNode.Support.TranslationZ.Equals(BH.oM.Structure.Constraints.DOFType.Fixed))
                {
                    nDof[0] = nodeDofs.Row(nodeIndex).At(2);
                    int index = bc.Column(0).Count;
                    bc = bc.InsertRow(index, nDof);
                }

                // Spring
                if (aNode.Support.TranslationX.Equals(BH.oM.Structure.Constraints.DOFType.Spring))
                {
                    temp[0] = nodeDofs.Row(nodeIndex).At(0);
                    temp[1] = aNode.Support.TranslationalStiffnessX;
                    int index = bc_stiffness.Column(0).Count;
                    bc_stiffness = bc_stiffness.InsertRow(index, temp);
                }
                if (aNode.Support.TranslationY.Equals(BH.oM.Structure.Constraints.DOFType.Spring))
                {
                    temp[0] = nodeDofs.Row(nodeIndex).At(1);
                    temp[1] = aNode.Support.TranslationalStiffnessY;
                    int index = bc_stiffness.Column(0).Count;
                    bc_stiffness = bc_stiffness.InsertRow(index, temp);
                }
                if (aNode.Support.TranslationZ.Equals(BH.oM.Structure.Constraints.DOFType.Spring))
                {
                    temp[0] = nodeDofs.Row(nodeIndex).At(2);
                    temp[1] = aNode.Support.TranslationalStiffnessZ;
                    int index = bc_stiffness.Column(0).Count;
                    bc_stiffness = bc_stiffness.InsertRow(index, temp);
                }
            }

            Vector <double> fext = DenseVector.Create(cullDup.Count * 3, 0);

            for (int i = 0; i < loads.Count; i++)
            {
                PointLoad   ptLoad    = loads[i];
                List <Node> loadNodes = ptLoad.Objects.Elements;
                int         a         = loadNodes.Count;

                for (int j = 0; j < a; j++)
                {
                    BH.oM.Structure.Elements.Node aNode = loadNodes[j];
                    int nodeIndex = cullDup.IndexOf(Geometry.Query.ClosestPoint(aNode.Position, cullDup));

                    fext[(int)nodeDofs.Row(nodeIndex).At(0) - 1] = ptLoad.Force.X;
                    fext[(int)nodeDofs.Row(nodeIndex).At(1) - 1] = ptLoad.Force.Y;
                    fext[(int)nodeDofs.Row(nodeIndex).At(2) - 1] = ptLoad.Force.Z;
                }
            }



            pres = DenseVector.Create(edof.RowCount, 0);

            for (int i = 0; i < ploads.Count; i++)
            {
                double     Load         = ploads[i].Prestress;
                List <Bar> loadElements = ploads[i].Objects.Elements;

                for (int j = 0; j < loadElements.Count; j++)
                {
                    int barIndex = bars.IndexOf(loadElements[j]);
                    pres[barIndex] = Load;
                }
            }


            edof = edof.InsertColumn(0, e);
            Edof = edof;
            BC   = bc.RemoveRow(0).Column(0);
            Fext = fext;


            if (bc_stiffness.RowCount > 1)
            {
                bcSprings = bc_stiffness.RemoveRow(0);
            }
            else
            {
                bcSprings = null;
            }
        }
Exemplo n.º 22
0
        private void Stream( ArrayList data, PointLoad pointload )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( PointLoad ) ) );

              data.Add( new Snoop.Data.Xyz( "Point", pointload.Point ) );
              data.Add( new Snoop.Data.Xyz( "Force", pointload.ForceVector ) );
              data.Add( new Snoop.Data.Xyz( "Moment", pointload.MomentVector ) );
        }
Exemplo n.º 23
0
 public void addPload(PointLoad load, Model karambaModel)
 {
     _ploads_table.Rows.Add("Point", load.node_ind, load.force, load.moment, load.loadcase);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Convert PointLoad point to Rhino point.
 /// </summary>
 internal static Rhino.Geometry.Point3d GetRhinoGeometry(this PointLoad pointLoad)
 {
     return(pointLoad.Load.GetFdPoint().ToRhino());
 }
Exemplo n.º 25
0
        public void DeformationTestIsotropicShellInPlane()
        {
            var nFaces     = 1;
            var length     = 1.0;
            var xIncMesh   = length / nFaces;
            var limit_dist = xIncMesh / 100.0;

            var y0 = 0.0;
            var y1 = 1.0;

            // create the mesh
            var mesh = new Mesh3((nFaces + 1) * 2, nFaces);

            mesh.AddVertex(new Point3(0, y0, 0));
            mesh.AddVertex(new Point3(0, y1, 0));
            for (var faceInd = 0; faceInd < nFaces; ++faceInd)
            {
                mesh.AddVertex(new Point3((faceInd + 1) * xIncMesh, y0, 0));
                mesh.AddVertex(new Point3((faceInd + 1) * xIncMesh, y1, 0));
                var nV = mesh.Vertices.Count;
                mesh.AddFace(nV - 4, nV - 3, nV - 1, nV - 2);
            }

            // create a shell
            MeshToShell.solve(new List <Point3>(), new List <Mesh3>()
            {
                mesh
            }, limit_dist, new List <string>(), new List <Color>(), new List <CroSec>(), true,
                              out List <Point3> outPoints, out List <BuilderShell> outBuilderShells, out MessageLogger outLogger);

            // create two supports
            var support1 = new Support(new Point3(0, y0, 0), new List <bool>()
            {
                true, true, true, true, true, true
            }, Plane3.Default);
            var support2 = new Support(new Point3(0, y1, 0), new List <bool>()
            {
                true, false, true, true, true, true
            }, Plane3.Default);

            // create two point loads
            var pl1 = new PointLoad(mesh.Vertices.Count - 2, new Vector3(25, 0, 0), new Vector3(), false);
            var pl2 = new PointLoad(mesh.Vertices.Count - 1, new Vector3(25, 0, 0), new Vector3(), false);

            // assemble the model
            var modelBuilder = new ModelBuilder(limit_dist);
            var model        = modelBuilder.build(new List <Point3>(), new List <FemMaterial>(), new List <CroSec>(),
                                                  new List <Support>()
            {
                support1, support2
            }, new List <Load>()
            {
                pl1, pl2
            }, outBuilderShells, new List <ElemSet>(),
                                                  new List <Joint>(), new MessageLogger()
                                                  );

            ThIAnalyze.solve(model, out var outMaxDisp, out var outG, out var outComp, out var warning, out model);

            Assert.AreEqual(outMaxDisp[0], 2.4858889456113236E-05, 1E-5);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Gets substruct (material block data) from file
        /// </summary>
        public void LoadSubstructData()
        {
            if (!File.Exists(FilePath))
            {
                MessageBox.Show("Could not find input data file.", "Error");
                return;
            }

            // get canvas dimensions/properties
            double originX = OriginOffsetX,
                   originY = OriginOffsetY,
                   scale   = Scale,
                   yHeight = ActualHeight;
            Units units    = Units;

            // get units dependent scaling factor
            double factor;

            switch (units)
            {
            case Units.Metres: factor = 0.0254; break;

            case Units.Millimetres: factor = 25.4; break;

            case Units.Feet: factor = 1.0 / 12.0; break;

            default: factor = 1.0; break;
            }

            // Load material blocks from source canvas
            substructs = new List <MaterialBlock>();
            using (TextReader tr = new StreamReader(FilePath))
            {
                // advance to material block data
                while (!tr.ReadLine().Contains("MATERIAL BLOCK DATA"))
                {
                    ;
                }

                tr.ReadLine();
                tr.ReadLine();

                int numMaterialBlocks = int.Parse(tr.ReadLine().Split('=')[1]);

                tr.ReadLine();

                if (numMaterialBlocks > 0)
                {
                    MaterialBlock  block;
                    MaterialType   mtl;
                    DrawingPoint   p1, p2;
                    LineConstraint newLC, existingLC;
                    LineLoad       newLL, existingLL;
                    PointLoad      newPL, existingPL;
                    Point[]        materialBoundPoints;
                    bool[]         isFixedX;
                    bool[]         isFixedY;
                    bool[]         isPrintPoint;
                    string         materialName;
                    int            numMaterialBoundPoints, numLineConstraints, numLineLoads, numPointLoads;
                    double         xCoord, yCoord;
                    string[]       coords, lineConstraint, lineLoad, pointLoad;

                    for (int i = 0; i < numMaterialBlocks; i++)
                    {
                        tr.ReadLine();

                        materialName = tr.ReadLine().Split(new char[] { '\"' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        mtl          = materialTypes.Find(delegate(MaterialType mt) { return(mt.Name == materialName); });

                        numMaterialBoundPoints = int.Parse(tr.ReadLine().Split('=')[1]);

                        materialBoundPoints = new Point[numMaterialBoundPoints];
                        isFixedX            = new bool[numMaterialBoundPoints];
                        isFixedY            = new bool[numMaterialBoundPoints];
                        isPrintPoint        = new bool[numMaterialBoundPoints];

                        for (int j = 0; j < numMaterialBoundPoints; j++)
                        {
                            coords = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            xCoord = double.Parse(coords[0]);
                            yCoord = double.Parse(coords[1]);
                            materialBoundPoints[j].X = xCoord / (factor * Scale) * dpiX + OriginOffsetX;
                            materialBoundPoints[j].Y = ActualHeight - (yCoord / (factor * Scale) * dpiY + OriginOffsetY);
                            isFixedX[j]     = coords[2] == bool.TrueString;
                            isFixedY[j]     = coords[3] == bool.TrueString;
                            isPrintPoint[j] = coords[4] == bool.TrueString;
                        }

                        block = new MaterialBlock(this, mtl, materialBoundPoints);
                        for (int j = 0; j < numMaterialBoundPoints; j++)
                        {
                            block.BoundaryPoints[j].IsFixedX     = isFixedX[j];
                            block.BoundaryPoints[j].IsFixedY     = isFixedY[j];
                            block.BoundaryPoints[j].IsPrintPoint = isPrintPoint[j];
                        }

                        substructs.Add(block);

                        numLineConstraints = int.Parse(tr.ReadLine().Split('=')[1]);
                        for (int j = 0; j < numLineConstraints; j++)
                        {
                            lineConstraint = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            p1 = block.BoundaryPoints[int.Parse(lineConstraint[0])];
                            p2 = block.BoundaryPoints[int.Parse(lineConstraint[1])];

                            existingLC = null;
                            foreach (MaterialBlock mb in substructs)
                            {
                                existingLC = mb.LineConstraints.Find(delegate(LineConstraint lc) { return(lc.Nodes.Contains(p1) && lc.Nodes.Contains(p2)); });
                                if (existingLC != null)
                                {
                                    break;
                                }
                            }

                            if (existingLC == null)
                            {
                                newLC = new LineConstraint(this, p1, p2,
                                                           //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                                                           //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                                                           lineConstraint[2] == bool.TrueString,
                                                           lineConstraint[3] == bool.TrueString);
                            }
                            else
                            {
                                block.LineConstraints.Add(existingLC);
                            }

                            //newLC = new LineConstraint( this ,
                            //    block.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                            //    block.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                            //    lineConstraint[2] == bool.TrueString ,
                            //    lineConstraint[3] == bool.TrueString );
                            //existingLC = null;
                            //foreach ( MaterialBlock mb in substructs )
                            //{
                            //    existingLC = mb.LineConstraints.Find(
                            //        delegate( LineConstraint lc )
                            //        {
                            //            return lc.Nodes.Contains( newLC.Nodes[0] ) && lc.Nodes.Contains( newLC.Nodes[1] );
                            //        } );
                            //    if ( existingLC != null ) break;
                            //}
                            //if ( existingLC != null )
                            //{
                            //    if ( !block.LineConstraints.Contains( existingLC ) )
                            //        block.LineConstraints.Add( existingLC );
                            //}
                            //else block.LineConstraints.Add( newLC );
                        }

                        numLineLoads = int.Parse(tr.ReadLine().Split('=')[1]);
                        for (int j = 0; j < numLineLoads; j++)
                        {
                            lineLoad = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            p1 = block.BoundaryPoints[int.Parse(lineLoad[0])];
                            p2 = block.BoundaryPoints[int.Parse(lineLoad[1])];

                            existingLL = null;
                            foreach (MaterialBlock mb in substructs)
                            {
                                existingLL = mb.LineLoads.Find(delegate(LineLoad ll) { return(ll.Nodes.Contains(p1) && ll.Nodes.Contains(p2)); });
                                if (existingLL != null)
                                {
                                    break;
                                }
                            }

                            if (existingLL == null)
                            {
                                newLL = new LineLoad(this, p1, p2,
                                                     //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                                                     //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                                                     lineLoad[2] == bool.TrueString, double.Parse(lineLoad[3]), double.Parse(lineLoad[4]),
                                                     lineLoad[5] == bool.TrueString, double.Parse(lineLoad[6]), double.Parse(lineLoad[7]));
                            }
                            else
                            {
                                block.LineLoads.Add(existingLL);
                            }

                            //block.LineLoads.Add( new LineLoad( this ,
                            //    block.BoundaryPoints[int.Parse( lineLoad[0] )] ,
                            //    block.BoundaryPoints[int.Parse( lineLoad[1] )] ,
                            //    lineLoad[2] == bool.TrueString , double.Parse( lineLoad[3] ) , double.Parse( lineLoad[4] ) ,
                            //    lineLoad[5] == bool.TrueString , double.Parse( lineLoad[6] ) , double.Parse( lineLoad[7] ) ) );
                        }

                        numPointLoads = int.Parse(tr.ReadLine().Split('=')[1]);
                        for (int j = 0; j < numPointLoads; j++)
                        {
                            pointLoad = tr.ReadLine().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            p1 = block.BoundaryPoints[int.Parse(pointLoad[0])];

                            existingPL = null;
                            foreach (MaterialBlock mb in substructs)
                            {
                                existingPL = mb.PointLoads.Find(delegate(PointLoad pl) { return(pl.Node == p1); });
                                if (existingPL != null)
                                {
                                    break;
                                }
                            }

                            if (existingPL == null)
                            {
                                newPL = new PointLoad(this, p1,
                                                      //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[0] )] ,
                                                      //newMaterialBlock.BoundaryPoints[int.Parse( lineConstraint[1] )] ,
                                                      pointLoad[1] == bool.TrueString, double.Parse(pointLoad[2]),
                                                      pointLoad[3] == bool.TrueString, double.Parse(pointLoad[4]));
                            }
                            else
                            {
                                block.PointLoads.Add(existingPL);
                            }

                            //block.PointLoads.Add( new PointLoad( this ,
                            //    block.BoundaryPoints[int.Parse( pointLoad[0] )] ,
                            //    pointLoad[1] == bool.TrueString , double.Parse( pointLoad[2] ) ,
                            //    pointLoad[3] == bool.TrueString , double.Parse( pointLoad[4] ) ) );
                        }



                        tr.ReadLine();
                    }
                }
            }

            // Set selected analysis phase to first (if present)
            if (source.AnalysisPhases.Count > 1)
            {
                ComboBox      phaseList = (ComboBox)((Grid)((GroupBox)((Grid)((ScrollViewer)((Grid)this.Parent).Children[2]).Content).Children[1]).Content).Children[1];
                AnalysisPhase initial   = source.AnalysisPhases[1];
                phaseList.SelectedItem = initial;
            }
        }