Editing wall sketches (Profile) using C#

Editing wall sketches (Profile) using C#

ahmadkhalaf7892
Advocate Advocate
465 Views
5 Replies
Message 1 of 6

Editing wall sketches (Profile) using C#

ahmadkhalaf7892
Advocate
Advocate

Hi Guys I have this normal wall here (generic 300mm)

Normal Wall.PNG

Edit Wall Sketch.PNG

Result.PNG

 I wanted to ask if there was any way I can edit the sketches of the wall ,I would have a line with two XYZ  Points, and I want to offset it with  a height of 3 units for example , what method should I use and how can I achieve that ?

0 Likes
466 Views
5 Replies
Replies (5)
Message 2 of 6

moturi.magati.george
Autodesk
Autodesk

Hi @ahmadkhalaf7892,

 

According to the thread below, the wall has no sketch lines, just a location line and thickness.

 

https://forums.autodesk.com/t5/revit-api-forum/access-sketch-lines-of-wall/td-p/8440417

 

 

  Moturi George,     Developer Advocacy and Support,  ADN Open
0 Likes
Message 3 of 6

jeremy_tammik
Alumni
Alumni

A wall with a sloped profile is fundamentally different from a "normal" wall:

 

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 4 of 6

jeremy_tammik
Alumni
Alumni

As always, you need to first study the end user approach and best practices to tackle the problem, before even starting to think about any programming aspects:

  

https://duckduckgo.com/?q=revit+sloped+wall

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 6

RPTHOMAS108
Mentor
Mentor

See:

Wall.SketchId (Invalid id if no sketch exists)

Wall.CreateProfileSketch

 

SketchEditScope.StartWithNewSketch (where no sketch exists)

SketchEditScope.Start (to edit an existing one)

 

So various options for creating a profile sketch to a wall. 

Note that only planar walls support profile sketches (see other limitations in Wall.CreateProfileSketch).

 

SketchEditScope.StartWithNewSketch provides an example for AnalyticalPanel (but a sketch is a sketch). Certain sketches are not supported by SketchEditScope but the wall profile one is as noted in:

'Revit Platform API Changes and Additions' (2022).

 

If you are ok will the ends of the wall being vertical you don't need to edit the sketch to achieve that wall, provided there is something to attach the top and the base to (which slopes).

 

 

Message 6 of 6

ahmadkhalaf7892
Advocate
Advocate

Hi Dear, I am using this code : 

FilteredElementCollector collector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType();
Level lev = collector.Where(e => e.Name.Contains("1")).First() as Level;

FilteredElementCollector wallTypeCollector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsElementType();
WallType wallType = wallTypeCollector.First(e => e.Name == "Generic - 200mm") as WallType;


// create an ilist for the curevs
IList<Curve> curves = new List<Curve>();
// create the Line
XYZ p1 = new XYZ(290.7636, -513.4871, 5.3993);
XYZ p2 = new XYZ(254.2638, -458.9748, 4.1806);
// adding an elevation of 32 units
XYZ p3 = new XYZ(0, 0, 32 ) + p2;
XYZ p4 = new XYZ(0, 0, 32 ) + p1;
// create the curves
// Represents the Line direction
Curve l1 = Line.CreateBound(p1, p2);
Curve l2 = Line.CreateBound(p2, p3);
Curve l3 = Line.CreateBound(p3, p4);
Curve l4 = Line.CreateBound(p4, p1);
curves.Add(l1);
curves.Add(l2);
curves.Add(l3);
curves.Add(l4);


Transaction transaction1 = new Transaction(doc);
transaction1.Start("Create Wall");
// Creating Wall
Wall w1 = Wall.Create(doc, curves, true);
Wall w2 = Wall.Create(doc, curves, wallType.Id, lev.Id, true);


 

It is creating a wall , However it's not taking the exact shapes of the curves that I want .  Any idea why ?