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.
Solved! Go to Solution.
Solved by JimJia. Go to Solution.
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; }
Can't find what you're looking for? Ask the community or share your knowledge.