Create rebars for manhole

because you don’t need it! this is what I’m trying to explain from the beginning…
Let’s recap:

  • in create_manhole_rebars you called the function with either walls[0] or walls[1] (using the previous notation here, but it works also with wall_1 and wall_2)
  • when you pass walls[0], the temp_line is built with walls[1]
  • when you pass walls[1], the temp_line is built with walls[0]

so this check is absolutely useless if you call the function directly with the other wall! no need for an if :wink:

And this is the same with the create_vertical_curveloop, you can just add another argument, let’s call it z_offset, and use that directly in the vectB

def create_vertical_curveloop(wall, c1, c2, d2, z_offset):
    ...
    vectB = XYZ(0, 0, z_offset)
    ...

def create_manhole_rebars(....):
    ...
    curveloop1 = create_vertical_curveloop(wall_1, c1, c2, d2, -c2)
    ...
    curveloop2 = create_vertical_curveloop(wall_2, c1, c2, d2, -d2)
    ...

No more need for walls (or wall_1 and wall_2) inside those functions, only on the main one.

Are you sure you copied the entire function? which line throws this exception, is it a line inside that function or elsewhere?

This is because of you’re still passing wall_width to get_covers_parameters in the main function, but you didn’t extract the width ftom the walls there.

Anyway, and sorry if I’m being pedantic (someday your future self will thank us both for that :wink:), but since the function is called get walls and not get_walls_and_the_width_of_the_first_wall :rofl: , it is less confusing to just return the walls and retrieve the width in the main function.

def get_walls(doc):
    """Return the first and second wall found in the document."""
    walls = FilteredElementCollector(doc).OfCategory(
    BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()
    return walls[:2]  # this will return the first 2 items of the list

def main(doc=None):
    ...
    walls = get_walls(doc)
    wall_width = walls[0].Width
    ...

Obviously the create_manhole_rebars will have to be changed accordingly to accept the width as another parameter instead of extracting it from walls.

2 Likes