.ToXyz() could not convert the Geometry's Units?


I am new to Python script for Dynamo.
I try to import Vector from Dynamo to Python script, but it seems Dynamo’s Geometry Conversion .ToXyz() could not convert the displacement vector’s units? I had to add the Unit Conversion in the script to adjust the displacement.

If I added the units conversion the element move the distance as I expected. I attached the Python script, please let me know if I understand something wrong? Revit 2018 Version 20170927_1515(x64) Dynamo Version

#clr Common Language Runtime
import clr

#Import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Import RevitAPI Classes
from Autodesk.Revit.DB import *

#Import geometry conversion extension methods
import Revit
#Adds ToDSType (bool) extension method to Wrapped elements
#Adds ToProtoType, ToRevitType geometry conversion extension methods to objects

ele = UnwrapElement(IN[0])
vectorTransform = IN[1].ToXyz()

doc = DocumentManager.Instance.CurrentDBDocument

#Modify Units
getDocUnits = doc.GetUnits()
getDisplayUnits = getDocUnits.GetFormatOptions(UnitType.UT_Length).DisplayUnits
unitConversion = UnitUtils.ConvertFromInternalUnits(1, getDisplayUnits )

vectorTransformUnits = vectorTransform/unitConversion
#Move Elementhttp://www.revitapidocs.com/2018.1/781ad017-5ee5-f44b-5db2-e8e1f883ae5d.htm
moveElement = ElementTransformUtils.MoveElement(doc, ele.Id, vectorTransformUnits)

OUT = moveElement

try calling ToXyz(true)

1 Like

Thanks, @Michael_Kirschner2

Yes, vectorTransform = IN[1].ToXyz(True) fix the problem.
I only new vectorTransform = IN[1].ToXyz(False) would ignore the units conversion.