<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create Floor from Wall in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/10383586#M25455</link>
    <description>&lt;P&gt;Tengo este script,que funciona en el revit 2021.Pero al cambiar al Revit 2022,cambia el metodo de creacion del suelo.&lt;/P&gt;&lt;P&gt;Alguna idea de como solucionarlo?&lt;/P&gt;&lt;P&gt;Aqui esta el script&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="Y2IQFc"&gt;I have this script, it works in revit 2021, but when switching to revit 2022, it changes the method of creating the floor.

Any idea how to fix it?

Here is the script&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Result result = Result.Succeeded;

            //Get UIDocument and Document
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document doc = uidoc.Document;

            //Initialize wall selection filter
            WallSelectionFilter wallSelection = new WallSelectionFilter();

            //Select the walls
            IList&amp;lt;Reference&amp;gt; references = uidoc.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element, wallSelection);

            if (references != null &amp;amp;&amp;amp; references.Count &amp;gt; 0)
            {
                //Initialize the curves list
                List&amp;lt;Curve&amp;gt; wallCurves = new List&amp;lt;Curve&amp;gt;();

                //Initialize the offsets list
                List&amp;lt;double&amp;gt; offsets = new List&amp;lt;double&amp;gt;();

                //Initialize the levels ids list
                List&amp;lt;ElementId&amp;gt; levelsIds = new List&amp;lt;ElementId&amp;gt;();

                foreach (var refer in references)
                {
                    Wall wall = (Wall)doc.GetElement(refer);

                    if (wall != null)
                    {
                        //Add the wall curve to the curves list
                        wallCurves.Add((wall.Location as LocationCurve).Curve);

                        //Add the wall curve to the curve list
                        offsets.Add(wall.Width / 2.0);

                        //Add the wall curve to the curves list
                        levelsIds.Add(wall.LevelId);

                    }

                    if (levelsIds.All(lvl =&amp;gt; lvl == levelsIds[0]))
                    {
                        CurveLoop ccu = CurveLoop.Create(wallCurves);
                       
                        //Create floor curve loop
                        CurveLoop ccud = CurveLoop.CreateViaOffset(ccu, offsets,new XYZ(0, 0, 1));

                        //Initialize the curve array
                        CurveArray curveArray = new CurveArray();

                        //Append the floor curves to the curve array
                        foreach (Curve c in ccud)
                        {
                            curveArray.Append(c);
                        }

                        //Get the level to model the floor
                        Level level = doc.GetElement(levelsIds[0]) as Level;

                        string floorTypeName = "Generic 300mm";

                        //Collect the floor type to be used
                        FloorType floorType = new FilteredElementCollector(doc).OfClass(typeof(FloorType))
                            .First(e =&amp;gt; e.Name.Equals(floorTypeName)) as FloorType;

                        using (Transaction tx = new Transaction(doc, "Wall to Floor"))
                        {
                            tx.Start();
                            try
                            {
                                //Create the floor
                                doc.Create.NewFloor(curveArray, floorType, level, false);// Revit API 2021

                                Floor.Create(doc, new List&amp;lt;CurveLoop&amp;gt; { ccud }, floorType.Id, level.Id);// Revit API 2022

                                //Commintchange to the model
                                tx.Commit();
                            }
                            catch (Exception e)
                            {
                                //Asign the error message to the user
                                message = e.Message;

                                //Roll back the model changes
                                tx.RollBack();

                                //Asign the result to failed
                                result = Result.Failed;
                            }
                        }
                    }
                    else
                    result = Result.Failed;
                }
            }
            else
            result = Result.Failed;
            return result;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Jun 2021 19:36:04 GMT</pubDate>
    <dc:creator>reylorente1</dc:creator>
    <dc:date>2021-06-11T19:36:04Z</dc:date>
    <item>
      <title>Create Floor from Wall</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/10383586#M25455</link>
      <description>&lt;P&gt;Tengo este script,que funciona en el revit 2021.Pero al cambiar al Revit 2022,cambia el metodo de creacion del suelo.&lt;/P&gt;&lt;P&gt;Alguna idea de como solucionarlo?&lt;/P&gt;&lt;P&gt;Aqui esta el script&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="Y2IQFc"&gt;I have this script, it works in revit 2021, but when switching to revit 2022, it changes the method of creating the floor.

Any idea how to fix it?

Here is the script&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Result result = Result.Succeeded;

            //Get UIDocument and Document
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document doc = uidoc.Document;

            //Initialize wall selection filter
            WallSelectionFilter wallSelection = new WallSelectionFilter();

            //Select the walls
            IList&amp;lt;Reference&amp;gt; references = uidoc.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element, wallSelection);

            if (references != null &amp;amp;&amp;amp; references.Count &amp;gt; 0)
            {
                //Initialize the curves list
                List&amp;lt;Curve&amp;gt; wallCurves = new List&amp;lt;Curve&amp;gt;();

                //Initialize the offsets list
                List&amp;lt;double&amp;gt; offsets = new List&amp;lt;double&amp;gt;();

                //Initialize the levels ids list
                List&amp;lt;ElementId&amp;gt; levelsIds = new List&amp;lt;ElementId&amp;gt;();

                foreach (var refer in references)
                {
                    Wall wall = (Wall)doc.GetElement(refer);

                    if (wall != null)
                    {
                        //Add the wall curve to the curves list
                        wallCurves.Add((wall.Location as LocationCurve).Curve);

                        //Add the wall curve to the curve list
                        offsets.Add(wall.Width / 2.0);

                        //Add the wall curve to the curves list
                        levelsIds.Add(wall.LevelId);

                    }

                    if (levelsIds.All(lvl =&amp;gt; lvl == levelsIds[0]))
                    {
                        CurveLoop ccu = CurveLoop.Create(wallCurves);
                       
                        //Create floor curve loop
                        CurveLoop ccud = CurveLoop.CreateViaOffset(ccu, offsets,new XYZ(0, 0, 1));

                        //Initialize the curve array
                        CurveArray curveArray = new CurveArray();

                        //Append the floor curves to the curve array
                        foreach (Curve c in ccud)
                        {
                            curveArray.Append(c);
                        }

                        //Get the level to model the floor
                        Level level = doc.GetElement(levelsIds[0]) as Level;

                        string floorTypeName = "Generic 300mm";

                        //Collect the floor type to be used
                        FloorType floorType = new FilteredElementCollector(doc).OfClass(typeof(FloorType))
                            .First(e =&amp;gt; e.Name.Equals(floorTypeName)) as FloorType;

                        using (Transaction tx = new Transaction(doc, "Wall to Floor"))
                        {
                            tx.Start();
                            try
                            {
                                //Create the floor
                                doc.Create.NewFloor(curveArray, floorType, level, false);// Revit API 2021

                                Floor.Create(doc, new List&amp;lt;CurveLoop&amp;gt; { ccud }, floorType.Id, level.Id);// Revit API 2022

                                //Commintchange to the model
                                tx.Commit();
                            }
                            catch (Exception e)
                            {
                                //Asign the error message to the user
                                message = e.Message;

                                //Roll back the model changes
                                tx.RollBack();

                                //Asign the result to failed
                                result = Result.Failed;
                            }
                        }
                    }
                    else
                    result = Result.Failed;
                }
            }
            else
            result = Result.Failed;
            return result;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 19:36:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/10383586#M25455</guid>
      <dc:creator>reylorente1</dc:creator>
      <dc:date>2021-06-11T19:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create Floor from Wall</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/10385656#M25456</link>
      <description>&lt;P&gt;Yes, the Document.NewFloor() methods have been deprecated in the 2022 API, and replaced with the Floor.Create() methods.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'll need to check which version of the application is running, and account for it inside your code. How you manage this ultimately depends on how you handle multi-targeting.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jun 2021 22:08:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/10385656#M25456</guid>
      <dc:creator>bhprest</dc:creator>
      <dc:date>2021-06-12T22:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create Floor from Wall</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/12774477#M25457</link>
      <description>&lt;P&gt;Hello, I would like to ask if you still have this project folder. Could you please share it with me for reference? I am currently working on an assignment related to this topic!!&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 09:47:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/12774477#M25457</guid>
      <dc:creator>anh00908668qv6e</dc:creator>
      <dc:date>2024-05-15T09:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create Floor from Wall</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/12775032#M25458</link>
      <description>&lt;P&gt;Si claro, pero no fue una carpeta, simplemente lo vi en algún lado, y lo quise reproducir.&lt;BR /&gt;Aqui está la solución correcta:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Yes, of course, but it wasn't a folder, I simply saw it somewhere, and I wanted to play it.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Here is the correct solution:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public Result Execute(
  ExternalCommandData commandData,
  ref string message,
  ElementSet elements)
{
    UIApplication uiapp = commandData.Application;
    UIDocument uidoc = uiapp.ActiveUIDocument;
    Application app = uiapp.Application;
    Document doc = uidoc.Document;

    Result result = Result.Succeeded;

    //Initialize wall selection filter
    WallSelectionFilter wallSelection = new WallSelectionFilter();

    //Select the walls
    IList&amp;lt;Reference&amp;gt; references = uidoc.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element, wallSelection);

    if (references != null &amp;amp;&amp;amp; references.Count &amp;gt; 0)
    {
        //Initialize the curves list
        List&amp;lt;Curve&amp;gt; wallCurves = new List&amp;lt;Curve&amp;gt;();

        //Initialize the offsets list
        IList&amp;lt;double&amp;gt; offsets = new List&amp;lt;double&amp;gt;();

        //Initialize the levels ids list
        List&amp;lt;ElementId&amp;gt; levelsIds = new List&amp;lt;ElementId&amp;gt;();

        foreach (var refer in references)
        {
            Wall wall = (Wall)doc.GetElement(refer);

            if (wall != null)
            {
                //Add the wall curve to the curves list
                wallCurves.Add((wall.Location as LocationCurve).Curve);

                //Add the wall curve to the curve list
                offsets.Add(wall.Width / 2.0);

                //Add the wall curve to the curves list
                levelsIds.Add(wall.LevelId);
            }
        }
        if (levelsIds.All(lvl =&amp;gt; lvl == levelsIds[0]))
        {
            CurveLoop ccu = CurveLoop.Create(wallCurves);

            //Create floor curve loop
            CurveLoop ccud = CurveLoop.CreateViaOffset(ccu, offsets, new XYZ(0, 0, 1));

            //Initialize the curve array
            CurveArray curveArray = new CurveArray();

            //Append the floor curves to the curve array
            foreach (Curve c in ccud)
            {
                curveArray.Append(c);
            }

            //Get the level to model the floor
            Level level = doc.GetElement(levelsIds[0]) as Level;

            string floorTypeName = "Generic 300mm";

            //Collect the floor type to be used
            FloorType floorType = new FilteredElementCollector(doc).OfClass(typeof(FloorType))
                .First(e =&amp;gt; e.Name.Equals(floorTypeName)) as FloorType;

            using (Transaction tx = new Transaction(doc, "Wall to Floor"))
            {
                tx.Start();
                try
                {
                    //Create the floor
                    //doc.Create.NewFloor(curveArray, floorType, level, false);// Revit API 2021

                    Floor.Create(doc, new List&amp;lt;CurveLoop&amp;gt; { ccud }, floorType.Id, level.Id);// Revit API 2022

                    //Commintchange to the model
                    tx.Commit();
                }
                catch (Exception e)
                {
                    //Asign the error message to the user
                    message = e.Message;

                    //Roll back the model changes
                    tx.RollBack();

                    //Asign the result to failed
                    result = Result.Failed;
                }
            }

        }
        else
            result = Result.Failed;
    }
    else
    result = Result.Failed;
    return result;

}
 public class WallSelectionFilter : ISelectionFilter
 {
     public bool AllowElement(Element elem)
     {
         return elem is Wall;
     }

     public bool AllowReference(Reference reference, XYZ position)
     {
         return false;
     }
     
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also in Revit 20... SDK, there is an example called, GenerateFloor. The ellipsis, depends on the year&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 14:06:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/12775032#M25458</guid>
      <dc:creator>reylorente1</dc:creator>
      <dc:date>2024-05-15T14:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create Floor from Wall</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/12778143#M25459</link>
      <description>&lt;P&gt;Thanks a lot!!!&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 15:17:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-floor-from-wall/m-p/12778143#M25459</guid>
      <dc:creator>anh00908668qv6e</dc:creator>
      <dc:date>2024-05-16T15:17:22Z</dc:date>
    </item>
  </channel>
</rss>

