Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating an offset walll

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Bruno_Neves_Pires_Silva
1212 Views, 2 Replies

Creating an offset walll

Hello,

 

  I am trying to create an offset wall, trying to use Jeremy's code (http://thebuildingcoder.typepad.com/blog/2013/09/creating-an-offset-wall.html), but its not working, the walls are overlapping. Can somebody give me some help ?

 

Here is the code I am using:

 

if (el is Wall)
{
Wall wall = el as Wall;

Autodesk.Revit.DB.LocationCurve cv =
el.Location as Autodesk.Revit.DB.LocationCurve;

using (Transaction t = new Transaction(doc, "bnps"))
{
t.Start();

Wall wall1 = Wall.Create(doc, cv.Curve, wall.LevelId, false);
Parameter param = wall1.get_Parameter(BuiltInParameter.WALL_KEY_REF_PARAM);
param.Set(3);

t.Commit();
}
}


Thanks in advance.

2 REPLIES 2
Message 2 of 3

Dear Bruno Silva,

 

If you want to create an offset, please use Transform.

Your code is only to change the location reference of the wall, does not create offset.

Please see codes below:

 

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Document doc = commandData.Application.ActiveUIDocument.Document;

            Reference r = commandData.Application.ActiveUIDocument.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "please select wall");

            Element el = doc.GetElement(r.ElementId);

            if (el is Wall)
            {
                Wall wall = el as Wall;
                Autodesk.Revit.DB.LocationCurve cv = el.Location as Autodesk.Revit.DB.LocationCurve;
                using (Transaction t = new Transaction(doc, "bnps"))
                {
                    t.Start();

                    //create location of new wall, use Transform
                    Curve newlocation = cv.Curve.CreateTransformed(Transform.CreateTranslation(wall.Orientation * 50));
                    Wall wall1 = Wall.Create(doc, newlocation, wall.LevelId, false);
                    t.Commit();
                }
            }

            return Result.Succeeded;
        }

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 3 of 3

Thank you very much, JimJia!!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community