Ejemplo n.º 1
0
        public static SpeckleElementsClasses.Floor ToSpeckle(this Autodesk.Revit.DB.Floor myFloor)
        {
            var speckleFloor = new SpeckleElementsClasses.Floor();

            speckleFloor.parameters = GetElementParams(myFloor);

            var geo = myFloor.get_Geometry(new Options()
            {
                DetailLevel = ViewDetailLevel.Medium
            });

            speckleFloor.floorType = myFloor.FloorType.Name;
            speckleFloor.baseCurve = getFloorOutline(myFloor);

            speckleFloor.ApplicationId = myFloor.UniqueId;
            speckleFloor.elementId     = myFloor.Id.ToString();
            speckleFloor.GenerateHash();

            (speckleFloor.Faces, speckleFloor.Vertices) = GetFaceVertexArrayFromElement(myFloor, new Options()
            {
                DetailLevel = ViewDetailLevel.Fine, ComputeReferences = false
            });

            return(speckleFloor);
        }
Ejemplo n.º 2
0
        public static Autodesk.Revit.DB.Floor ToNative(this SpeckleElementsClasses.Floor mySlab)
        {
            var(docObj, stateObj) = GetExistingElementByApplicationId(mySlab.ApplicationId, mySlab.Type);

            //if( stateObj != null && Convert.ToBoolean( stateObj.Properties[ "userModified" ] ) == false && docObj != null )
            //{
            //  return docObj as Autodesk.Revit.DB.Floor;
            //}

            var slabCurves = new CurveArray();
            var segments   = GetSegmentList(mySlab.baseCurve);

            foreach (var x in segments)
            {
                slabCurves.Append(x);
            }

            if (mySlab.level == null)
            {
                mySlab.level = new SpeckleElementsClasses.Level()
                {
                    createView = true, elevation = segments[0].GetEndPoint(0).Z / Scale
                }
            }
            ;

            // NOTE: I have not found a way to edit a slab outline properly, so whenever we bake, we renew the element.
            if (docObj != null)
            {
                Doc.Delete(docObj.Id);
            }

            if (mySlab.floorType == null)
            {
                var myNullTypeFloor = Doc.Create.NewFloor(slabCurves, false);

                SetElementParams(myNullTypeFloor, mySlab.parameters);
                return(myNullTypeFloor);
            }

            FloorType type = (FloorType)GetElementByClassAndName(typeof(Autodesk.Revit.DB.FloorType), mySlab.floorType);

            var fltype = GetElementByName(typeof(FloorType), mySlab.floorType);

            var myTypeBasedFloor = Doc.Create.NewFloor(slabCurves, type, ((Autodesk.Revit.DB.Level)mySlab.level.ToNative()), false);

            SetElementParams(myTypeBasedFloor, mySlab.parameters);
            return(myTypeBasedFloor);
        }