Example #1
0
        public static Grevit.Types.Profile ToGrevitProfile(this SketchUpNET.Surface surface, SketchUpNET.Transform t = null)
        {
            Types.Profile profile = new Types.Profile();
            profile.profile = new List <Loop>();

            Loop outerloop = new Loop();

            outerloop.outline = new List <Types.Component>();
            foreach (SketchUpNET.Edge corner in surface.OuterEdges.Edges)
            {
                outerloop.outline.Add(corner.ToGrevitLine(t));
            }

            profile.profile.Add(outerloop);


            foreach (SketchUpNET.Loop skploop in surface.InnerEdges)
            {
                Loop innerloop = new Loop();

                innerloop.outline = new List <Types.Component>();
                foreach (SketchUpNET.Edge corner in skploop.Edges)
                {
                    innerloop.outline.Add(corner.ToGrevitLine(t));
                }

                profile.profile.Add(innerloop);
            }

            return(profile);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.Profile profile = null;
            if (!DA.GetData("Profile", ref profile))
            {
                return;
            }
            DA.SetData("ProfileName", profile.Value.GetName);
            DA.SetData("ProfileSize", profile.Value.GetShape);
            DA.SetData("ProfileStandard", profile.Value.GetStandard);
            var profileLoops = profile.Value.GetProfileCurves();
            var treeArray    = new GH_Structure <GH_Curve>();

            for (int i = 0; i < profileLoops.Count; i++)
            {
                foreach (var curve in profileLoops[i])
                {
                    var ghPath  = new GH_Path(i);
                    var ghCurve = new GH_Curve(curve.ToRhino());
                    treeArray.Append(ghCurve, ghPath);
                }
            }
            DA.SetDataTree(3, treeArray);
        }
Example #3
0
        public static Grevit.Types.Profile ToGrevitProfile(this SketchUpNET.Surface surface, SketchUpNET.Transform t = null)
        {
            Types.Profile profile = new Types.Profile();
            profile.profile = new List<Loop>();

            Loop outerloop = new Loop();

            outerloop.outline = new List<Types.Component>();
            foreach (SketchUpNET.Edge corner in surface.OuterEdges.Edges)
                outerloop.outline.Add(corner.ToGrevitLine(t));

            profile.profile.Add(outerloop);


            foreach (SketchUpNET.Loop skploop in surface.InnerEdges)
            {
                Loop innerloop = new Loop();

                innerloop.outline = new List<Types.Component>();
                foreach (SketchUpNET.Edge corner in skploop.Edges)
                    innerloop.outline.Add(corner.ToGrevitLine(t));

                profile.profile.Add(innerloop);
            }

            return profile;
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (!_needBake || !PlugIn.LinkedDocument.IsActive)
            {
                return;
            }

            /*Extract input parameters*/
            IGH_GeometricGoo geometry = null;

            if (!DA.GetData("Geometry", ref geometry))
            {
                return;
            }

            var elementType = Bricscad.Bim.BimTypeElement.BimGenericBuildingElt;

            Types.ElementType type = null;
            if (DA.GetData("ElementType", ref type))
            {
                elementType = type.Value;
            }

            Bricscad.Bim.BIMSpatialLocation spatialLocation = null;
            Types.SpatialLocation           location        = null;
            if (DA.GetData("SpatialLocation", ref location))
            {
                spatialLocation = location.Value;
            }

            var objIds = BakeGhGeometry(geometry);

            if (objIds == null)
            {
                return;
            }

            Bricscad.Bim.BIMProfile bimProfile = null;
            Types.Profile           profile    = null;
            if (DA.GetData("Profile", ref profile))
            {
                var dummy = new Bricscad.Bim.BIMProfile(profile.Value);
                if (dummy.SaveProfile(PlugIn.LinkedDocument.Database) == Bricscad.Bim.BimResStatus.Ok)
                {
                    bimProfile = dummy;
                }
            }

            var createdProfileId = _OdDb.ObjectId.Null;

            _OdDb.ObjectEventHandler objAppended = (s, e) => createdProfileId = e.DBObject.ObjectId;
            PlugIn.LinkedDocument.Database.ObjectAppended += objAppended;
            var curvesToDelete = new _OdDb.ObjectIdCollection();

            for (int i = 0; i < objIds.Count; ++i)
            {
                var id = objIds[i];
                spatialLocation?.AssignToEntity(id);
                Bricscad.Bim.BIMClassification.ClassifyAs(id, elementType);
                bimProfile?.ApplyProfileTo(id, 0, true);
                //replace curve with created solid profile
                if (DatabaseUtils.isCurve(id) && !createdProfileId.IsNull)
                {
                    curvesToDelete.Add(id);
                    objIds[i]        = createdProfileId;
                    createdProfileId = _OdDb.ObjectId.Null;
                }
            }
            DatabaseUtils.EraseObjects(curvesToDelete);
            PlugIn.LinkedDocument.Database.ObjectAppended -= objAppended;
            var res = new List <Types.BcEntity>();

            foreach (_OdDb.ObjectId objId in objIds)
            {
                DA.SetData("BuildingElement",
                           new Types.BcEntity(new _OdDb.FullSubentityPath(new _OdDb.ObjectId[] { objId }, new _OdDb.SubentityId()), PlugIn.LinkedDocument.Name));
            }
        }
Example #5
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.Assembly assembly = new Types.Assembly();
            DA.GetData <Types.Assembly>("Material", ref assembly);

            GH_Curve  curve  = new GH_Curve();
            GH_Number radius = new GH_Number(0);
            GH_Number height = new GH_Number(0);
            GH_Number width  = new GH_Number(0);

            Types.Profile profile = null;

            if (!DA.GetData <GH_Number>("Radius", ref radius))
            {
                radius.Value = 0;
            }
            if (!DA.GetData <GH_Number>("Height", ref height))
            {
                height.Value = 0;
            }
            if (!DA.GetData <GH_Number>("Width", ref width))
            {
                width.Value = 0;
            }
            if (!DA.GetData <Types.Profile>("Profile", ref profile))
            {
                profile = null;
            }
            DA.GetData <GH_Curve>("Curve", ref curve);

            double calculationVolume = 0;


            if (profile != null)
            {
                calculationVolume = curve.Value.GetLength() * profile.Area;
                drawColumn(curve.Value.PointAtStart, curve.Value.PointAtEnd, profile.Area);
            }
            else
            {
                if (radius.Value > 0)
                {
                    drawColumn(curve.Value.PointAtStart, curve.Value.PointAtEnd, radius.Value);
                    calculationVolume = curve.Value.GetLength() * radius.Value * radius.Value * Math.PI;
                }
                else
                {
                    drawColumn(curve.Value.PointAtStart, curve.Value.PointAtEnd, height.Value, width.Value);
                    calculationVolume = curve.Value.GetLength() * height.Value * width.Value;
                }
            }



            Types.Result result = new Types.Result()
            {
                GlobalWarmingPotential     = new Types.UnitDouble <Types.LCA.CO2e>(assembly.GlobalWarmingPotential.Value * calculationVolume),
                Acidification              = new Types.UnitDouble <Types.LCA.kgSO2>(assembly.Acidification.Value * calculationVolume),
                DepletionOfNonrenewbles    = new Types.UnitDouble <Types.LCA.MJ>(assembly.DepletionOfNonrenewbles.Value * calculationVolume),
                DepletionOfOzoneLayer      = new Types.UnitDouble <Types.LCA.kgCFC11>(assembly.DepletionOfOzoneLayer.Value * calculationVolume),
                Eutrophication             = new Types.UnitDouble <Types.LCA.kgPhostphate>(assembly.Eutrophication.Value * calculationVolume),
                FormationTroposphericOzone = new Types.UnitDouble <Types.LCA.kgNOx>(assembly.FormationTroposphericOzone.Value * calculationVolume)
            };



            DA.SetData("LCA Result", result);
        }