XYZ to vector

Hi!
I have a XYZ in revitapi, can I get its vector to an angel, say 30 degree?


sorry the pic is a bit ugly.
I can achieve this in dynamo using point.asvector, then vector rotate. But I want to do it using revitapi.

Thanks!

ok maybe get the basisY first from XYZ, then Transform.CreateRotation?

Hello
using the Transform class
Revit API use the same class for Points and Vectors (XYZ)

import clr
import sys
import System
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

xyz_before = XYZ(0,5,0)
axis = XYZ.BasisZ
angle = 30.0 * 0.0174533 # in radian
#transform
tf = Transform.CreateRotationAtPoint(axis, angle, xyz_before)
xyz_after = tf.OfVector(xyz_before)

# convert to ProtoGeometry
OUT = xyz_before.ToVector(), xyz_after.ToVector()

3 Likes

for it is even hard to get the result in dynamo @newshunhk

thank you! this is exactly what I am looking for!