Creating beams from wall lines

Creating beams from wall lines

adarsh_aromabim
Participant Participant
850 Views
7 Replies
Message 1 of 8

Creating beams from wall lines

adarsh_aromabim
Participant
Participant

I'm trying to create beams along the edges of a wall face when the face is selected. However, while the beams are created properly along the lines, the orientation of the beams are different across the different edges. But more importantly, the orientations of the beams are different across the different planes of the wall faces.

 

This is my code - 

 

selected_el_ref = selection.PickObject(ObjectType.Face)
selected_el = doc.GetElement(selected_el_ref)

# Check if selected element is wall
selected_wall = selected_el if type(selected_el) == Wall else None

wall_face = selected_wall.GetGeometryObjectFromReference(
    selected_el_ref) if selected_wall else None

normal = wall_face.FaceNormal
origin = wall_face.Origin
curve_loops = wall_face.GetEdgesAsCurveLoops()
level = doc.GetElement(selected_wall.LevelId)

beam_type = FilteredElementCollector(doc).OfCategory(
            BuiltInCategory.OST_StructuralFraming).OfClass(FamilySymbol).FirstElement()

for curve_loop in curve_loops:
    for curve in curve_loop:
        beam = doc.Create.NewFamilyInstance( curve, beam_type, level, Structure.StructuralType.Beam)
 
If I select a wall face in the YZ plane, then these are the beams that are created. 
YZ-plane.pngYZ-plane-closeup.png
From the above pictures, it can be seen that the cross-section rotation and the yJustification are off along the different lines in the same plane.
 
XZ-plane.png
After that, I chose an XZ plane and applied a uniform cross section rotation of 90 degrees to all the lines but from the above picture you can see that the top line is different from the rest. 
 
45deg-closeup.png
The real problem comes in when I chose a wall that is at an angle. The above picture is the beam creation when I choose a wall that is created at 45 degrees in the XY plane. From the picture, it can be seen that the beam on the side of the wall is at a 45 degree angle. When I set the cross section rotation to 45 degrees, it gets fixed. 
 
I have tried all methods, I created a code to make sure all the lines are in one direction and they're oriented in clockwise direction as per the normal of the selected face but none of the changes works.
 
How do I create a generic program wherein when I select a wall face, it places the beams with a uniform cross section rotation and yJustification w.r.t the face that is chosen and not the XYZ coordinate system?
0 Likes
Accepted solutions (1)
851 Views
7 Replies
Replies (7)
Message 2 of 8

jeremy_tammik
Alumni
Alumni

I would hazard that it depends very much on the definition of the beam family. One way that might help simplify things significantly might be to define a beam family with the location line in the center of the beam profile instead of along one of its edges.

  

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

adarsh_aromabim
Participant
Participant

So this is the default beam family that comes with Revit and the location line is already in the center of the beam profile.

But even if it wasn't shouldn't it only affect the yJustification of the beams, why are the cross section rotations of the beam creation dependent on the coordinates of the plane? 

Is there another method to create beams that uses both the lines and the face of the wall?

0 Likes
Message 4 of 8

jeremy_tammik
Alumni
Alumni

It looks to me as if you are using an H beam with the location line on one side of one of the H side legs:

  

beam_location_45deg.png

   

The middle of the beam profile would be the middle of the H crossbar

  

The placement of the beam is determined by placing its location line at the curve that you specify. 

  

I assume that its rotation can be adjusted using the LocationLine Rotate method:

  

   

When you place the beams along the face edges manually in the UI, do they automatically adjust and connect in the desired manner? If so, it might be worth while trying to make use of that functionality programmatically as well.

   

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

adarsh_aromabim
Participant
Participant

profile.png

This is the profile that I am using, which shows the location line going through the middle and not the end.

 

Rotation

For rotation, my question is should I manually set the rotation of each line because the rotation angle of the beams on each of the 4 lines depends heavily on the plane of the wall face, as it is different on the XZ plane, YZ plane and even on a 45 degree plane where even the beam rotates at 45 degrees from the above pictures. Is it possible to have a generic beam creation method that creates the beam without taking into consideration the orientation of the plane? Or can I create a beam using the plane along with the line?

0 Likes
Message 6 of 8

jeremy_tammik
Alumni
Alumni

Oh, how weird. So the green lines in your image are not the location lines? How sad. It looks to me as if (a large part of) your problem would be solved if you could ensure that the beam location line coincides with the creating curve. So, what are those green lines, then?

   

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

adarsh_aromabim
Participant
Participant

Ah sorry for the confusion, the green lines are just the curves(lines) of the wall face that are chosen. These green lines are what I am using to create the beams. For some reason, the location lines are not coinciding with the creating curve. Moreover, the rotation of the beams don't seem to be uniform. I suspect both the rotation and the location are heavily dependent on the plane (XYZ) of the wall face which maybe why depending upon the wall face plane, both the rotation and the location lines are changing. I'm more concerned about the rotation of the beams as I want that to be uniform across all lines in one plane and across all planes as well.

0 Likes
Message 8 of 8

adarsh_aromabim
Participant
Participant
Accepted solution

Solved this by first ensuring that all the lines are in one direction, for example clockwise or anticlockwise for uniformity across all the planes. Unfortunately, couldn't find any generic fix for having a correct rotation and yJustification for the beams, but found that there is almost a generic formula for a fixed Z axis, so had to manually create some formulas for the angle of rotations for each beam along the different axes. So if the wall is in XZ plane, each of the 4 lines follow a particular fixed angle of rotation and YZ plane has its own set of rotation angles for each line. For any plane in between these two, we just have to angle with the XZ plane (or YZ plane) with the corresponding fixed angle of rotations.

0 Likes