/// <summary> /// Creates a piece of furniture. /// </summary> /// <param name="properties"> Properties of the object.</param> private FamilyInstance CreateFurniture(FurnitureProperty properties) { if (properties is null) { throw new ArgumentNullException(nameof(properties)); } // get the properties double rotation = DeegreToRadians(properties.Rotation); XYZ p0 = GetXYZFromProperties(properties.Coordinate.ElementAt(0)); XYZ p1 = GetXYZFromProperties(properties.Coordinate.ElementAt(1)); XYZ point = (p0 + p1) / 2; string fsFamilyName = GetFamilySymbolName(properties.Type); UV offset = GetFamilyOffset(properties.Type); offset = new UV(UnitUtils.ConvertToInternalUnits(offset.U, UnitTypeId.Meters), UnitUtils.ConvertToInternalUnits(offset.V, UnitTypeId.Meters)); offset = VectorManipulator.RotateVector(offset, rotation + baseRotation); // Creates a point above the furniture to serve as a rotation axis XYZ axisPoint = new XYZ(point.X, point.Y, baseLevel.Elevation + 1); Line axis = Line.CreateBound(point, axisPoint); FamilyInstance furniture; try { FamilySymbol familySymbol = revitDB.GetFamilySymbol(fsFamilyName); Autodesk.Revit.DB.Structure.StructuralType structuralType = Autodesk.Revit.DB.Structure.StructuralType.NonStructural; furniture = doc.Create.NewFamilyInstance(point, familySymbol, structuralType); ElementTransformUtils.RotateElement(doc, furniture.Id, axis, rotation + baseRotation); ElementTransformUtils.MoveElement(doc, furniture.Id, VectorManipulator.TransformUVinXYZ(offset)); } catch (Exception e) { throw new Exception("Erro ao inserir mobiliario \"" + fsFamilyName + "\".", e); } return(furniture); }