Esempio n. 1
0
        public static object To_DynamoObj_sPointSupport(sPointSupport pointSupport)
        {
            sDynamoConverter dyncon = new sDynamoConverter("Meters", "Feet");

            Dyn.Point lp = (Dyn.Point)dyncon.EnsureUnit((dyncon.ToDynamoPoint(pointSupport.location)));

            Dyn.Vector force = null;
            if (pointSupport.reaction_force != null)
            {
                force = dyncon.EnsureUnit_Force(dyncon.ToDynamoVector(pointSupport.reaction_force));
            }
            Dyn.Vector moment = null;
            if (pointSupport.reaction_moment != null)
            {
                moment = dyncon.EnsureUnit_Force(dyncon.ToDynamoVector(pointSupport.reaction_moment));
            }

            return(new Dictionary <string, object>
            {
                { "location", lp },
                { "supportType", pointSupport.supportType.ToString() },
                { "constraints", pointSupport.constraints },
                { "reactionForce", force },
                { "reactionMoment", moment },
            });
        }
Esempio n. 2
0
        public static object To_DynamoMeshData(sSystem sghSystem, double colorThreshold = 0.0, double deformation = 0.0)
        {
            List <List <Dyn.Point> > vertice    = null;
            List <List <int> >       faceIndice = null;
            List <List <int> >       Rs         = null;
            List <List <int> >       Gs         = null;
            List <List <int> >       Bs         = null;

            if (sghSystem != null)
            {
                sDynamoConverter dyncon = new sDynamoConverter();

                sRange th = null;
                if (colorThreshold > 0.0)
                {
                    th = new sRange(0.0, colorThreshold);
                }
                dyncon.ToDynamoToolKitMeshData(sghSystem, eColorMode.Stress_Combined_Absolute, out vertice, out faceIndice, out Rs, out Gs, out Bs, deformation, th);
            }

            return(new Dictionary <string, object>
            {
                { "vertice", vertice },
                { "indice", faceIndice },
                { "R", Rs },
                { "G", Gs },
                { "B", Bs }
            });
        }
Esempio n. 3
0
        public static object AppendMesh(sSystem sghSystem, string meshName, List <double> verticeNineNumbers, int colorA, int colorR, int colorG, int colorB)
        {
            sDynamoConverter dycon = new sDynamoConverter("Feet", "Meters");

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

            for (int i = 0; i < sghSystem.meshes.Count; ++i)
            {
                if (sghSystem.meshes[i].meshName == meshName)
                {
                    sghSystem.meshes.RemoveAt(i);
                }
            }

            sMesh sm = dycon.TosMesh(dycon.EnsureUnit(verticeNineNumbers), new sColor(colorA, colorR, colorG, colorB));

            sm.meshName = meshName;

            sghSystem.meshes.Add(sm);

            foreach (sMesh mm in sghSystem.meshes)
            {
                meshNames.Add(mm.meshName);
            }

            return(new Dictionary <string, object>
            {
                { "sSystem", sghSystem },
                { "AppendedMeshNames", meshNames }
            });
        }
Esempio n. 4
0
        public static object To_DynamoObj_sPointLoad(sPointLoad pointLoad)
        {
            sDynamoConverter dyncon = new sDynamoConverter("Meters", "Feet");

            Dyn.Point lp = (Dyn.Point)dyncon.EnsureUnit((dyncon.ToDynamoPoint(pointLoad.location)));
            //Dyn.PolyCurve pc = (Dyn.PolyCurve) dyncon.EnsureUnit((dyncon.ToDynamoPolyCurve(pointLoad.tributaryArea.areaBoundary)));

            Dyn.Vector force = null;
            if (pointLoad.forceVector != null)
            {
                force = dyncon.ToDynamoVector(dyncon.EnsureUnit(pointLoad).forceVector);
            }
            Dyn.Vector moment = null;
            if (pointLoad.momentVector != null)
            {
                moment = dyncon.ToDynamoVector(dyncon.EnsureUnit(pointLoad).momentVector);
            }

            return(new Dictionary <string, object>
            {
                { "location", lp },
                { "loadPattern", pointLoad.loadPatternName },
                { "forceVec", force },
                { "momentVec", moment }
            });
        }
Esempio n. 5
0
        public static object To_DynamoObj_sBeamPreview(sFrame beam)
        {
            sDynamoConverter dyncon = new sDynamoConverter("Meters", "Feet");

            return(new Dictionary <string, object>
            {
                { "beamPreview", dyncon.EnsureUnit(dyncon.ToDynamoBeamPreview(beam)) }
            });
        }
Esempio n. 6
0
        public static object To_DynamoObj_sLineLoad(sLineLoad lineLoad)
        {
            sDynamoConverter dyncon = new sDynamoConverter("Meters", "Feet");

            return(new Dictionary <string, object>
            {
                { "loadPattern", lineLoad.loadPatternName },
                { "loadType", lineLoad.loadType.ToString() },
                { "loadForce", dyncon.EnsureUnit_Force(dyncon.ToDynamoVector(lineLoad.load_Force)) },
                { "loadMoment", dyncon.EnsureUnit_Force(dyncon.ToDynamoVector(lineLoad.load_Moment)) }
            });
        }
Esempio n. 7
0
        public static object To_DynamoObj_sBeam(sFrame beam)
        {
            sDynamoConverter dyncon = new sDynamoConverter("Meters", "Feet");

            return(new Dictionary <string, object>
            {
                { "beamName", beam.frameName },
                { "beamID", beam.frameID },
                { "beamLine", dyncon.EnsureUnit(dyncon.ToDynamoLine(beam.axis)) },
                { "crossSection", beam.crossSection },
                { "lineLoads", beam.lineLoads }
            });
        }
Esempio n. 8
0
        public static object Get_sRectangularSection(sMaterial material, double width_in, double depth_in, double thickness_in = 0.0)
        {
            sCrossSection cs     = new sCrossSection();
            string        shapeN = "";

            if (Math.Abs(width_in - depth_in) < 0.0001)
            {
                cs.sectionType = eSectionType.SQUARE;
                shapeN        += "Square_" + width_in + "x" + depth_in;
            }
            else
            {
                cs.sectionType = eSectionType.RECTANGLAR;
                shapeN        += "Rectangular_" + width_in + "x" + depth_in;
            }
            if (thickness_in > 0.0)
            {
                shapeN += "x" + thickness_in;
            }

            sDynamoConverter dycon = new sDynamoConverter("Feet", "Meters");

            width_in     /= 12.0;
            depth_in     /= 12.0;
            thickness_in /= 12.0;


            width_in     = Math.Round(width_in, 3);
            depth_in     = Math.Round(depth_in, 3);
            thickness_in = Math.Round(thickness_in, 3);

            cs.dimensions = new List <double>();
            cs.dimensions.Add(dycon.EnsureUnit_Dimension(width_in));
            cs.dimensions.Add(dycon.EnsureUnit_Dimension(depth_in));
            if (thickness_in > 0.0)
            {
                cs.dimensions.Add(dycon.EnsureUnit_Dimension(thickness_in));
            }

            cs.shapeName = shapeN;

            cs.material = material;

            return(new Dictionary <string, object>
            {
                { "sCrossSection", cs }
            });
        }
Esempio n. 9
0
        public static object sBeamSetByCurves(string beamSetName, List <Dyn.Curve> beamSetCurves, List <sCrossSection> crossSections)
        {
            List <sFrameSet> sets = new List <sFrameSet>();
            //how to get Revit Unit?...
            sDynamoConverter dycon = new sDynamoConverter("Feet", "Meters");

            for (int i = 0; i < beamSetCurves.Count; ++i)
            {
                double len = beamSetCurves[i].Length;
                if (len > 0.005)
                {
                    Dyn.Curve dc     = dycon.EnsureUnit(beamSetCurves[i]) as Dyn.Curve;
                    sCurve    setCrv = dycon.TosCurve(Dyn.PolyCurve.ByJoinedCurves(new Dyn.Curve[] { dc }));
                    sFrameSet bset   = new sFrameSet(setCrv);
                    bset.frameSetName = beamSetName;
                    bset.setId        = i;

                    if (crossSections.Count == 1)
                    {
                        bset.crossSection = crossSections[0] as sCrossSection;
                    }
                    else if (crossSections.Count == beamSetCurves.Count)
                    {
                        bset.crossSection = crossSections[i] as sCrossSection;
                    }

                    sets.Add(bset);
                    dc.Dispose();
                }
            }

            //for(int i = 0; i < beamSetCurves.Count; ++i)
            //{
            //    beamSetCurves[i].Dispose();
            //}

            return(new Dictionary <string, object>
            {
                { "sBeamSets", sets }
            });
        }
Esempio n. 10
0
        public static object Get_sRoundSection(sMaterial material, double diameter_in, double thickness_in = 0.0)
        {
            sCrossSection cs = new sCrossSection();

            eSectionType stype = eSectionType.ROUND;

            cs.sectionType = stype;

            string shapeN = "Round_" + diameter_in;

            if (thickness_in > 0.0)
            {
                shapeN += "x" + thickness_in;
            }

            cs.shapeName = shapeN;
            sDynamoConverter dycon = new sDynamoConverter("Feet", "Meters");

            diameter_in  /= 12.0;
            thickness_in /= 12.0;


            diameter_in  = Math.Round(diameter_in, 3);
            thickness_in = Math.Round(thickness_in, 3);

            cs.dimensions = new List <double>();
            cs.dimensions.Add(dycon.EnsureUnit_Dimension(diameter_in));
            if (thickness_in > 0.0)
            {
                cs.dimensions.Add(dycon.EnsureUnit_Dimension(thickness_in));
            }


            cs.material = material;

            return(new Dictionary <string, object>
            {
                { "sCrossSection", cs }
            });
        }
Esempio n. 11
0
        public static object To_DynamoMesh_Appendix(sSystem sghSystem)
        {
            List <Dyn.Mesh>      emesh        = new List <Dyn.Mesh>();
            List <List <Color> > verticeColor = null;

            if (sghSystem != null)
            {
                sDynamoConverter dyncon = new sDynamoConverter("Meters", "Feet");

                foreach (sMesh sm in sghSystem.meshes)
                {
                    List <Color> vcols;
                    emesh.Add(dyncon.ToDynamoMesh(sm, out vcols));
                    verticeColor.Add(vcols);
                }
            }

            return(new Dictionary <string, object>
            {
                { "dynamoMesh", emesh }
            });
        }
Esempio n. 12
0
        public static object To_GroupPointLoad_ByPattern(List <sPointLoad> pointLoads)
        {
            sDynamoConverter dyncon = new sDynamoConverter("Meters", "Feet");

            List <List <sPointLoad> > plGroup = new List <List <sPointLoad> >();
            var grouped = pointLoads.GroupBy(l => l.loadPatternName);

            foreach (var lgroup in grouped)
            {
                List <sPointLoad> plList = new List <sPointLoad>();
                foreach (sPointLoad pl in lgroup)
                {
                    plList.Add(pl);
                }
                plGroup.Add(plList);
            }

            return(new Dictionary <string, object>
            {
                { "pointLoadGroup", plGroup }
            });
        }
Esempio n. 13
0
        public static object To_GroupBeam_ByName(List <sFrame> beams)
        {
            sDynamoConverter dyncon = new sDynamoConverter("Meters", "Feet");

            List <List <sFrame> > plGroup = new List <List <sFrame> >();
            var grouped = beams.GroupBy(l => l.frameName);

            foreach (var lgroup in grouped)
            {
                List <sFrame> plList = new List <sFrame>();
                foreach (sFrame pl in lgroup)
                {
                    plList.Add(pl);
                }
                plGroup.Add(plList);
            }

            return(new Dictionary <string, object>
            {
                { "beamGroup", plGroup }
            });
        }
Esempio n. 14
0
        public static object SplitSegmentize(List <object> sElements, double intersectTolerance = 0.015, double segmentLength = 1.5)
        {
            sDynamoConverter dycon = new sDynamoConverter("Feet", "Meters");

            List <object>    pelements    = new List <object>();
            List <sFrameSet> beamelements = new List <sFrameSet>();

            foreach (object iso in sElements)
            {
                sFrameSet fs = iso as sFrameSet;
                if (fs != null)
                {
                    beamelements.Add(fs);
                    continue;
                }
                sPointLoad pl = iso as sPointLoad;
                if (pl != null)
                {
                    pelements.Add(pl);
                    continue;
                }
                sPointSupport ps = iso as sPointSupport;
                if (ps != null)
                {
                    pelements.Add(ps);
                    continue;
                }
            }

            dycon.SplitSegmentizesBeamSet(ref beamelements, intersectTolerance, segmentLength, pelements);

            return(new Dictionary <string, object>
            {
                { "sBeamSets", beamelements },
                { "sPointElements", pelements }
            });
        }
Esempio n. 15
0
        public static object sPointSupport(List <Dyn.Point> points, int supportType, string nodeName = "")
        {
            List <sPointSupport> nodes = new List <sPointSupport>();

            sDynamoConverter rhcon = new sDynamoConverter("Feet", "Meters");

            if (supportType == 0 || supportType == 1)
            {
                for (int i = 0; i < points.Count; ++i)
                {
                    Dyn.Point dp = rhcon.EnsureUnit(points[i]) as Dyn.Point;
                    sXYZ      sp = rhcon.TosXYZ(dp);

                    sPointSupport n = new sPointSupport();
                    n.location = sp;

                    if (supportType == 0)
                    {
                        n.supportType = eSupportType.FIXED;
                    }
                    else if (supportType == 1)
                    {
                        n.supportType = eSupportType.PINNED;
                    }

                    nodes.Add(n);
                    dp.Dispose();
                }
            }


            return(new Dictionary <string, object>
            {
                { "sPointSupport", nodes }
            });
        }
Esempio n. 16
0
        public static object Build_sSystem(List <object> sElements, object systemSettings = null)
        {
            sSystemSetting sysSet = null;

            if (systemSettings == null)
            {
                sysSet = new sSystemSetting();
                sysSet.systemOriUnit = "Feet";

                sysSet.systemName       = "DefaultSetting";
                sysSet.currentCase      = "DEAD";
                sysSet.currentCheckType = eSystemCheckType.StrengthCheck;

                sysSet.currentStressThreshold_pascal = 25 * 6894757.28;
                sysSet.currentDeflectionThreshold_mm = 100;

                sysSet.mergeTolerance_m = 0.005;
                sysSet.meshDensity_m    = 0.5;
            }
            else
            {
                sysSet = systemSettings as sSystemSetting;
            }

            sSystem jsys = new sSystem();

            jsys.systemSettings = sysSet;
            List <IsObject>  sobjs = new List <IsObject>();
            sDynamoConverter dycon = new sDynamoConverter();

            jsys.loadPatterns.Add("DEAD");

            int supCount = 0;
            int nodeID   = 0;

            foreach (object so in sElements)
            {
                sFrameSet sb = so as sFrameSet;
                if (sb != null)
                {
                    jsys.frameSets.Add(sb);
                    sobjs.Add(sb);

                    if (sb.lineLoads != null)
                    {
                        foreach (sLineLoad ll in sb.lineLoads)
                        {
                            jsys.AwarePatternNames(ll.loadPatternName);
                        }
                    }
                    continue;
                }

                sPointSupport psup = so as sPointSupport;
                if (psup != null)
                {
                    if (jsys.UpdateNodeFromPointElement(psup, nodeID))
                    {
                        nodeID++;
                    }
                    supCount++;
                    continue;
                }

                sPointLoad pl = so as sPointLoad;
                if (pl != null)
                {
                    if (jsys.UpdateNodeFromPointElement(pl, nodeID))
                    {
                        nodeID++;
                        jsys.AwarePatternNames(pl.loadPatternName);
                    }
                    continue;
                }

                sLoadCombination com = so as sLoadCombination;
                if (com != null)
                {
                    jsys.SetLoadCombination(com);
                }
            }

            if (supCount > 0)
            {
                //jsys.geometrySettings.systemBoundingBox = dycon.TosBoundingBox(sobjs);
                //jsys.SystemName = sysSet.systemName;
                return(new Dictionary <string, object>
                {
                    { "sSystem", jsys }
                });
            }
            else
            {
                return(new Dictionary <string, object>
                {
                    { "sSystem", null }
                });
            }
        }
Esempio n. 17
0
        public static object AwareTributaryArea_ByPoints(Dyn.Surface boundarySrf, List <Dyn.Point> pointsForLoad, bool flipDirection)
        {
            sDynamoConverter dycon = new sDynamoConverter("Feet", "Meters");

            List <Dyn.UV> uvs = new List <Dyn.UV>();


            //double fac = 10;
            //if (flipDirection) fac *= -1;
            //foreach (Dyn.Curve seg in Dyn.PolyCurve.ByJoinedCurves(boundarySrf.PerimeterCurves()).Offset(fac).Explode())
            //{
            //    uvs.Add(boundarySrf.UVParameterAtPoint(seg.PointAtParameter(0.5)));
            //}
            foreach (Dyn.Point lp in pointsForLoad)
            {
                uvs.Add(boundarySrf.UVParameterAtPoint(lp));
            }
            List <Dyn.Surface> vorocut = new List <Dyn.Surface>();

            foreach (var vc in Voronoi.ByParametersOnSurface(uvs, boundarySrf))
            {
                Dyn.Curve vcc = vc as Dyn.Curve;

                Dyn.Geometry[] ints = boundarySrf.Intersect(vcc);
                if (ints != null && ints.Length > 0)
                {
                    for (int i = 0; i < ints.Length; ++i)
                    {
                        if (ints[i] is Dyn.Curve)
                        {
                            Dyn.Curve   ic   = ints[i] as Dyn.Curve;
                            Dyn.Surface isrf = ic.Extrude(Dyn.Vector.ZAxis().Scale(5));
                            vorocut.Add(isrf);
                        }
                        else
                        {
                            object t = ints[i];
                        }
                    }
                }
            }
            List <Dyn.Surface> voroPattern = new List <Dyn.Surface>();
            List <double>      voroArea    = new List <double>();
            List <Dyn.Point>   lpts        = new List <Dyn.Point>();

            Dyn.PolySurface vorocutPoly = Dyn.PolySurface.ByJoinedSurfaces(vorocut);
            Dyn.Geometry[]  splited     = boundarySrf.Split(vorocutPoly);
            for (int i = 0; i < splited.Length; ++i)
            {
                Dyn.Surface vsrf = splited[i] as Dyn.Surface;
                if (vsrf != null)
                {
                    //voroPattern.Add(Dyn.PolyCurve.ByJoinedCurves(vsrf.PerimeterCurves()));
                    voroPattern.Add(vsrf);
                    voroArea.Add(vsrf.Area);

                    foreach (Dyn.Point lp in pointsForLoad)
                    {
                        if (lp.DistanceTo(vsrf) < 0.005)
                        {
                            lpts.Add(lp);
                            break;
                        }
                    }
                }
            }


            //vorocutPoly.Dispose();

            return(new Dictionary <string, object>
            {
                { "LoadPoints", lpts },
                { "TributaryAreaSrfs", voroPattern },
                { "TributaryArea", voroArea }
            });
        }