Increase Floor Size

Increase Floor Size

Anonymous
Not applicable
1,310 Views
11 Replies
Message 1 of 12

Increase Floor Size

Anonymous
Not applicable

I want to increase the size of floor, how I increase the size of floor? I written code for it but it does not increase the size of a floor but it transform from one location to another.

 

 

This is my code:-

 

List<ModelLine> mLines = new List<ModelLine>();
                 
                using (Transaction t = new Transaction(doc, "DrawBeam"))
                {

                    t.Start();
                        FilteredElementCollector floor =new FilteredElementCollector(doc,doc.ActiveView.Id);
                        floor.OfClass(typeof(Floor));
                
                        foreach(Floor f in floor)
                        {
                            BoundingBoxXYZ bb=f.get_BoundingBox(null);
                            if (f is ModelLine)
                            {
                                mLines.Add(bb as ModelLine);
                            }
                        }
                        
                        foreach (ModelLine mline in mLines)
                        {
                LocationCurve lCurve = mline.Location as LocationCurve;
                Line c = lCurve.Curve as Line;
                XYZ pt1 = c.GetEndPoint(0);
                XYZ pt2 = c.GetEndPoint(1);
                XYZ xyz=new XYZ(5,5,5);
                 
                XYZ pt1New =xyz+pt1;
                XYZ pt2New = xyz+pt2; 

                Line newLine = Line.CreateBound(pt1, pt2);
                lCurve.Curve = newLine;
                        }

0 Likes
1,311 Views
11 Replies
Replies (11)
Message 2 of 12

Revitalizer
Advisor
Advisor

Hi,

 

have a look at the CurveLoop.CreateViaOffset method.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 3 of 12

Anonymous
Not applicable

I study about CurveLoop.CreateViaOffset method but I didn't understand how to use this method and where? Please tell me how to use this method?

 

Thank you for giving me response.

0 Likes
Message 4 of 12

Revitalizer
Advisor
Advisor

Hi,

 

first, get the outer loop of your floor.

The floor may contain openings, so there may be several loops.

Take the curves and create a CurveLoop object from them.

Get the desired offset CurveLoop by  using the CurveLoop.CreateViaOffset method.

Use the new CurveLoop's curves, create a CurveArray from them to create a new Floor object.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 12

Anonymous
Not applicable

How to take curves and create CurveLoop object from them?

0 Likes
Message 6 of 12

Revitalizer
Advisor
Advisor

Hi,

 

CurveLoop.Create takes an IList<Curve> as an argument, just read RevitAPI.chm.

To get the boundary curves of a floor, analyze its top or bottom faces, I would suppose.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 7 of 12

Anonymous
Not applicable

I create like this-

IList<Curve> curve=new List<Curve>();
 CurveLoop.Create(curve);

 

Where to define this lines in my code?

I posted my code if it possible can you change my code?

0 Likes
Message 8 of 12

Revitalizer
Advisor
Advisor

Hi,

 

fill your "curve" variable before using it in the CurveLoop constructor.

 

For getting the Curve objects, there are several postings on the TBC blog.

Just type in "floor" in the search textbox.

 

http://thebuildingcoder.typepad.com/blog/2013/07/create-a-floor-with-an-opening-or-complex-boundary....

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 9 of 12

Anonymous
Not applicable

 I am trying to fill curve with floor max and min values of x,y,z axix  but it showing errror.Plz explain me with the code how to increase the size of floor?

0 Likes
Message 10 of 12

jeremytammik
Autodesk
Autodesk

You cannot easily modify the size of an existing floor, afaik.

 

You can retrieve the profile of an existing floor and create a new floor from that:

 

http://thebuildingcoder.typepad.com/blog/2008/11/editing-a-floor-profile.html

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 11 of 12

Anonymous
Not applicable

I written the same code but it showing me error

 

This is the code:-

 

 

using System.Collections.Generic;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;

namespace FloorEditor
{
class Class1:IExternalCommand
{
PlanarFace GetTopFace(Solid solid)
{
PlanarFace topFace = null;
FaceArray faces = solid.Faces;
foreach (Face f in faces)
{
PlanarFace pf = f as PlanarFace;
if (null != pf
&& Util.IsHorizontal(pf))
{
if ((null == topFace)
|| (topFace.Origin.Z < pf.Origin.Z))
{
topFace = pf;
}
}
}
return topFace;
}
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Application app = commandData.Application;
Document doc = app.ActiveDocument;

List<RvtElement> floors = new List<RvtElement>();
if (!Util.GetSelectedElementsOrAll(
floors, doc, typeof(Floor)))
{
Selection sel = doc.Selection;
message = (0 < sel.Elements.Size)
? "Please select some floor elements."
: "No floor elements found.";
return CmdResult.Failed;
}

int nNullFaces = 0;
List<Face> topFaces = new List<Face>();
Options opt = app.Create.NewGeometryOptions();

foreach (Floor floor in floors)
{
GeometryElement geo = floor.get_Geometry(opt);
GeometryObjectArray objects = geo.Objects;
foreach (GeometryObject obj in objects)
{
Solid solid = obj as Solid;
if (solid != null)
{
PlanarFace f = GetTopFace(solid);
if (null == f)
{
Debug.WriteLine(
Util.ElementDescription(floor)
+ " has no top face.");
++nNullFaces;
}
topFaces.Add(f);
}
}
}

Autodesk.Revit.Creation.Application creApp = app.Create;
Autodesk.Revit.Creation.Document creDoc = doc.Create;

int i = 0;
int n = topFaces.Count - nNullFaces;

Debug.WriteLine(string.Format(
"{0} top face{1} found.",
n, Util.PluralSuffix(n)));

foreach (Face f in topFaces)
{
if (null != f)
{
CurveArray profile = new CurveArray();
EdgeArrayArray eaa = f.EdgeLoops;

EdgeArray ea = eaa.get_Item(0);
foreach (Edge e in ea)
{
XYZArray pts = e.Tessellate();
int m = pts.Size;
XYZ p = pts.get_Item(0);
XYZ q = pts.get_Item(m - 1);
Line line = Line.CreateBound(p, q);
profile.Append(line);
}
Floor floor = floors[i++] as Floor;
floor = creDoc.NewFloor(profile, floor.FloorType, floor.Level, true);
doc.Move(floor, new XYZ(5, 5, 0));
}
}
return Result.Succeeded;
}
}
}

 

0 Likes
Message 12 of 12

Revitalizer
Advisor
Advisor

Hi,

 

it would be useful to get more info about the exception you are talking about...

 

Also, why tesselating an edge for creating a line if you just can use the original curve (edge.AsCurve()...) ?

Floor could have round edges.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes