public static BeamBase FromSpeckle(SpeckleBrep BaseObj)
        {
            if ((string)BaseObj.Properties[GlobalVar.discriminator] != "BeamBase")
            {
                throw new Exception("Can't convert to BeamBase, missing discriminator.");
            }

            using (RhinoConverter rhConv = new RhinoConverter())
            {
                var myBeamBase = new BeamBase();

                myBeamBase.MainVolume = (Brep)rhConv.ToNative(BaseObj);

                myBeamBase.DetailedVolume = (Brep)rhConv.ToNative((SpeckleObject)BaseObj.Properties["DetailedVolume"]);

                myBeamBase.TopLeftCurve = (Curve)rhConv.ToNative((SpeckleObject)BaseObj.Properties["TopLeft"]);

                myBeamBase.TopRightCurve = (Curve)rhConv.ToNative((SpeckleObject)BaseObj.Properties["TopRight"]);

                myBeamBase.BottomRightCurve = (Curve)rhConv.ToNative((SpeckleObject)BaseObj.Properties["BottomRight"]);

                myBeamBase.BottomLeftCurve = (Curve)rhConv.ToNative((SpeckleObject)BaseObj.Properties["BottomLeft"]);

                return(myBeamBase);
            }
        }
Пример #2
0
        public override object ToNative(SpeckleObject _object)
        {
            if ((string)_object.Properties[GlobalVar.discriminator] == "BeamBase")
            {
                return(BeamBase.FromSpeckle(((SpeckleBrep)_object)));
            }
            if ((string)_object.Properties[GlobalVar.discriminator] == "DetailedBeam")
            {
                return(DetailedBeam.FromSpeckle(((SpeckleBrep)_object)));
            }
            if ((string)_object.Properties[GlobalVar.discriminator] == "BeamJoint")
            {
                return(BeamJoint.FromSpeckle(((SpecklePoint)_object)));
            }

            // Graceful fail
            using (RhinoConverter rhConv = new RhinoConverter())
                return(rhConv.ToNative(_object));
        }