[VBA CE] Rotate AboutXAboutYAboutZ from given angle of each view

In the geotechnical world, in 2D drawing state it is very common to see 3 rotation angles.

That is still ok if you have angle for 2 axis only. However, I have no idea to make correct angles of each view when 3 axis.

My general method to rotate the element: (wrong)

ele.Rotate Point3dZero, Radians(x), 0, 0
ele.Rotate Point3dZero, 0, Radians(y), 0
ele.Rotate Point3dZero, 0, 0, Radians(z)

Example of desired result:

Parents
  • Hi,

    However, I have no idea to make correct angles of each view when 3 axis.

    My general method to rotate the element: (wrong)

    I am not sure if I understand your situation right, because a contradiction exists in your question: You are not sure about "angles of each view", but in your code, you rotate an element.

    Do you want to defined a view, so the element in "base position" looks rotated in the defined ways, or you want to rotate the element three times to display it in the three defined positions?

    it is very common to see 3 rotation angles.

    The question is in what rotation angles are you interested in. Euler angles, mentioned by Jon, are widely used and well defined concept, but from your picture it seems you are interested in some "other angles" (Euler angles are not perpendicular, whether your picture is expressed in a standard top/front/side way).

    My general method to rotate the element: (wrong)

    Yes, it is wrong, because e.g. when an object should be rotated 20° around X and 30° around Y, it cannot be constructed like rotate around X and after that rotate around Y. Look e.g. this (I think every nice) video.

    With regards,

      Jan

  • You are not sure about "angles of each view", but in your code, you rotate an element.

    The Government would like to prompt BIM and they took some as-built examples to consultant and requested them to built in 3D Model with Revit.  So, I would like to make sure that is the limitation of Revit or that is a unsolvable problem.

    Do you want to defined a view, so the element in "base position" looks rotated in the defined ways, or you want to rotate the element three times to display it in the three defined positions?

    From the as-built drawing, they provided the Top View, Front View and  Right View and the required Angle (or inclination). That "looks" very nice because 3 dimensional view should have enough information to form a 3D model. But I cannot find the way to create directly / rotate element to satisfy the requirement of 3 views. 

    The question is in what rotation angles are you interested in

    I am interested in how to know the rotation angles when you have a given answer from 3 views. It is because when you rotate second times about another axis, the original wanted rotation angle will lose. Matrix Term, the formula provide you only new XYZ and rotation angle, but I don't know both of them and I have only 3 rotation angles from 3 different views.

  • So, I would like to make sure that is the limitation of Revit or that is a unsolvable problem.

    Why do you think its a limitation of Revit, or even unsolvable (in what exactly)?

    But I cannot find the way to create directly / rotate element to satisfy the requirement of 3 views. 

    Like this example, where rotation around X = 30°, Y=45° and Z= 60°?

    First I do the rotations manually, then automated and you will note that the rotations are not done around 0,0,0 either:

    Its quite straight-forward if you keep the Matrix rotations separated and performed in the correct sequence.

  • Why do you think its a limitation of Revit, or even unsolvable (in what exactly)?

    There are lots of incorrect parametric Revit models compared with the original 2D Drawings. You can review how worse of the BIM Object are incorrectly modeled and published on the Government webpage. For example, soil nails modeling cannot satisfy the 50mm cover between the head the bar. So, I think that there must be some limitations with 3 fixed rotation in Revit. I even cannot draw a correct line with Microstation.

    rotation around X = 30°, Y=45° and Z= 60°?

    Um.... you have rotated element, but what I am looking for is how to find the rotations from the result, e.g. After rotations, from Top View you can see that is Z=60, Front View you can see that is y=45, and on the Right View X=30. That should be a reverse engineering to track back the rotations and orders.

  • Hi,

    the following code example may help to understand how a single transformation (matrices + pivot point) can be created from 3 rotations about x,y and z in a single step.
    A rotation can be expressed with a rotation matrix and several rotation matrices combined with a pivot results in a transformation.

    Hope that helps.

    Best regards,

    Artur


    Example to rotate selected elements about point (0,0,0) in x (30°),y (45°) and z (60°) direction in a single step:

    Sub RotateElementExample()
    Dim ee As elementEnumerator
    Dim oEle As Element
    Dim matX As Matrix3d
    Dim matY As Matrix3d
    Dim matZ As Matrix3d
    Dim mat As Matrix3d
    Dim trans As Transform3d
    Dim pPivot As Point3d
    Set ee = ActiveModelReference.GetSelectedElements
    Do While ee.MoveNext
        If ee.Current.IsGraphical Then
            Set oEle = ee.Current
            
            'Matrix3dFromAxisAndRotationAngle (Axis, Radians)
            
            'rotate about z-axis 30°:
            matX = Matrix3dFromAxisAndRotationAngle(0, Radians(30)) ' The axis index 0=x, 1=y, 2=z
            
            'rotate about y-axis 45°:
            matY = Matrix3dFromAxisAndRotationAngle(1, Radians(45)) ' The axis index 0=x, 1=y, 2=z
            
            'rotate about x-axis 60°:
            matZ = Matrix3dFromAxisAndRotationAngle(2, Radians(60)) ' The axis index 0=x, 1=y, 2=z
            
            'multiply the 3 matrices to combine the rotation to single step
            
            mat = Matrix3dFromMatrix3dTimesMatrix3dTimesMatrix3d(matX, matY, matZ)
            
            ' Add a Pivot point to the matrix and the transformation is ready and can be applied to the element:
            pPivot = Point3dFromXYZ(0, 0, 0)
            
            ' Define Transformation from Matrix and Pivot point
            trans = Transform3dFromMatrix3dAndFixedPoint3d(mat, pPivot)
            
            ' Apply transformation
            oEle.Transform trans
            oEle.Rewrite
            
        End If
    Loop
    End Sub
    

  • but what I am looking for is how to find the rotations from the result

    In future, it would be advisable to make that aim absolutely clear in both the thread subject and original post, currently neither does that.

    There are lots of incorrect parametric Revit models compared with the original 2D Drawings.

    The same can be said of drawings or models made in any software, ultimately it depends on the knowledge and ability of the user.

    For example, soil nails modeling cannot satisfy the 50mm cover between the head the bar. So, I think that there must be some limitations with 3 fixed rotation in Revit.

    I'm not sure of what the specific issue you refer to is, but typically many Revit families are hosted onto a system family, e.g. Window/Door onto a wall. You can place families in unhosted but knowing how it should be orientated is not easy. In the case of the Soil Nails, I imagine they would be modelled parallel to XYZ axis (or View Side, Front, Top) with rotation parameters added as necessary to flex the family. However, if its placed unhosted, how do you define the directional vector which represents the YZ (for example) plane of the Soil Nail installed into the ground? I think you need to be provide some clarity on what the perceived issue is.

    I even cannot draw a correct line with Microstation.

    Likewise, clarify what problem you are having

  • In future, it would be advisable to make that aim absolutely clear in both the thread subject and original post, currently neither does that.
    Likewise, clarify what problem you are having
    Like this example, where rotation around X = 30°, Y=45° and Z= 60°?

    Is the topic not clear? Ok.... I simplify it into a line. Forget about the 3d solid. I want to create a line from point(0,0,0) to somewhere. And then rotate the view, Flatten direction to view will be like that:

    Question: where should be the second point of the line?

  • Is the topic not clear?

    I think you can see its not as Artur did exactly what I did.

    Question: where should be the second point of the line?

    The answer to that depends on the length of the line. I can't give you an answer via a programmatical solution but its quite easy enough to work out manually, just draw 3 different lines, extrude them using Extrude Surface and you can find the Line by using Planar Slice (By Element)

    Answer Verified By: clever_anthony 

  • Thanks, I can now get the point first by program and then normalize the vector. When you have the destination point, and then you can calculate the Direction and Elevation angle, so actually we don't need three rotations in this case.

Reply Children
No Data