Пример #1
0
        public static object SnowDrift_ByEdgeHeight(Dyn.Curve edgeCurve, bool flipDirectioin, double snowLoad_ground_psf, double snowLoad_flatRoof_psf, double roofLength_lower_ft, double roofLength_upper_ft, double roofHeight_delta_ft, double adjustmentFactor_ft = 10.0)
        {
            sDynamoUtilities dynutil = new sDynamoUtilities();

            double designLen;
            double designHeight;
            double designMaxLoad;
            double designSnowDensity;

            dynutil.GetSnowDriftInformation(snowLoad_ground_psf, snowLoad_flatRoof_psf, roofHeight_delta_ft, roofLength_lower_ft, roofLength_upper_ft, out designLen, out designHeight, out designMaxLoad, out designSnowDensity);

            double fac = designLen;

            if (flipDirectioin)
            {
                fac *= -1;
            }

            Dyn.PolyCurve edgeCrvEx = Dyn.PolyCurve.ByJoinedCurves(new Dyn.Curve[1] {
                edgeCurve.ExtendStart(adjustmentFactor_ft).ExtendEnd(adjustmentFactor_ft)
            });
            Dyn.PolyCurve driftCrv_onRoof = Dyn.PolyCurve.ByJoinedCurves(new Dyn.Curve[1] {
                edgeCrvEx.Offset(fac)
            });
            Dyn.PolyCurve driftCrv_onEdge = Dyn.PolyCurve.ByJoinedCurves(new Dyn.Curve[1] {
                edgeCrvEx.Translate(Dyn.Vector.ZAxis().Scale(designHeight)) as Dyn.Curve
            });

            List <Dyn.Solid> snows = new List <Dyn.Solid>();

            for (int i = 0; i < driftCrv_onRoof.NumberOfCurves; ++i)
            {
                List <Dyn.PolyCurve> cs = new List <Dyn.PolyCurve>();
                cs.Add(Dyn.PolyCurve.ByPoints(new Dyn.Point[3] {
                    driftCrv_onRoof.CurveAtIndex(i).StartPoint, driftCrv_onEdge.CurveAtIndex(i).StartPoint, edgeCrvEx.CurveAtIndex(i).StartPoint
                }, true));
                cs.Add(Dyn.PolyCurve.ByPoints(new Dyn.Point[3] {
                    driftCrv_onRoof.CurveAtIndex(i).EndPoint, driftCrv_onEdge.CurveAtIndex(i).EndPoint, edgeCrvEx.CurveAtIndex(i).EndPoint
                }, true));
                snows.Add(Dyn.Solid.ByLoft(cs));
            }

            Dyn.Solid snowSolid = Dyn.Solid.ByUnion(snows);

            // edgeCrvEx.Dispose();
            // driftCrv_onEdge.Dispose();
            // driftCrv_onRoof.Dispose();

            return(new Dictionary <string, object>
            {
                { "DesignLength_ft", designLen },
                { "DesignHeight_ft", designHeight },
                { "DesignMaxLoad_psf", designMaxLoad },
                { "DesignDensity_pcf", designSnowDensity },
                { "DrfitVolumeSolid", snowSolid },
            });
        }
Пример #2
0
        public static Dictionary <string, Autodesk.DesignScript.Geometry.Curve[]> OffsetPerimeterCurves(this Autodesk.DesignScript.Geometry.Surface surface, double offset)
        {
            List <Autodesk.DesignScript.Geometry.Curve> srfPerimCrvs = surface.PerimeterCurves().ToList();

            Autodesk.DesignScript.Geometry.PolyCurve plyCrv = Autodesk.DesignScript.Geometry.PolyCurve.ByJoinedCurves(srfPerimCrvs);

            double inOffset;
            double outOffset;

            if (offset < 0)
            {
                inOffset  = offset;
                outOffset = -offset;
            }
            else
            {
                inOffset  = -offset;
                outOffset = offset;
            }

            Autodesk.DesignScript.Geometry.Curve[] inPerimCrvs;
            try
            {
                List <Autodesk.DesignScript.Geometry.Curve> inOffsetCrv = new List <Autodesk.DesignScript.Geometry.Curve>()
                {
                    (plyCrv.Offset(inOffset))
                };
                Autodesk.DesignScript.Geometry.PolyCurve    inOffsetPolyCrv = Autodesk.DesignScript.Geometry.PolyCurve.ByJoinedCurves(inOffsetCrv);
                List <Autodesk.DesignScript.Geometry.Curve> inOffsetCrvList = inOffsetPolyCrv.Curves().ToList();
                List <Autodesk.DesignScript.Geometry.Point> inPts           = new List <Autodesk.DesignScript.Geometry.Point>();
                foreach (Autodesk.DesignScript.Geometry.Curve c in inOffsetCrvList)
                {
                    inPts.Add(c.StartPoint);
                }
                Autodesk.DesignScript.Geometry.PolyCurve inOffsetPolyCrv2 = PolyCurve.ByPoints(inPts, true);
                Autodesk.DesignScript.Geometry.Surface   inOffsetSrf      = Autodesk.DesignScript.Geometry.Surface.ByPatch(inOffsetPolyCrv2);
                inPerimCrvs = inOffsetSrf.PerimeterCurves();
                inOffsetSrf.Dispose();
                inOffsetPolyCrv.Dispose();
                inOffsetPolyCrv2.Dispose();
            }
            catch (Exception)
            {
                inPerimCrvs = null;
            }

            Autodesk.DesignScript.Geometry.Curve[] outPerimCrvs;
            try
            {
                List <Autodesk.DesignScript.Geometry.Curve> outOffsetCrv = new List <Autodesk.DesignScript.Geometry.Curve>()
                {
                    (plyCrv.Offset(outOffset))
                };
                Autodesk.DesignScript.Geometry.PolyCurve    outOffsetPolyCrv = Autodesk.DesignScript.Geometry.PolyCurve.ByJoinedCurves(outOffsetCrv);
                List <Autodesk.DesignScript.Geometry.Curve> outOffsetCrvList = outOffsetPolyCrv.Curves().ToList();
                List <Autodesk.DesignScript.Geometry.Point> outPts           = new List <Autodesk.DesignScript.Geometry.Point>();
                foreach (Autodesk.DesignScript.Geometry.Curve c in outOffsetCrvList)
                {
                    outPts.Add(c.StartPoint);
                }
                Autodesk.DesignScript.Geometry.PolyCurve outOffsetPolyCrv2 = PolyCurve.ByPoints(outPts, true);
                Autodesk.DesignScript.Geometry.Surface   outOffsetSrf      = Autodesk.DesignScript.Geometry.Surface.ByPatch(outOffsetPolyCrv2);
                outPerimCrvs = outOffsetSrf.PerimeterCurves();
                outOffsetSrf.Dispose();
                outOffsetPolyCrv.Dispose();
                outOffsetPolyCrv2.Dispose();
            }
            catch (Exception)
            {
                outPerimCrvs = null;
            }


            Dictionary <string, Autodesk.DesignScript.Geometry.Curve[]> newOutput;

            newOutput = new Dictionary <string, Autodesk.DesignScript.Geometry.Curve[]>
            {
                { "insetCrvs", inPerimCrvs },
                { "outsetCrvs", outPerimCrvs }
            };

            //Dispose all redundant geometry

            plyCrv.Dispose();
            foreach (Autodesk.DesignScript.Geometry.Curve c in srfPerimCrvs)
            {
                c.Dispose();
            }

            return(newOutput);
        }