GetTotalTransform method in walltypes

Hello Y’all, I have the following script

# Copyright(c) 2017, Dimitar Venkov
# @5devene, dimitar.ven@gmail.com
# www.badmonkeys.net

import clr

clr.AddReference("RevitAPIUI")
from  Autodesk.Revit.UI import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import RevitLinkInstance, FamilyInstance

def output1(x):
	if len(x) == 1: return x[0]
	else : return x

sel1 = uidoc.Selection
ot1 = Selection.ObjectType.Element
ot2 = Selection.ObjectType.PointOnElement
li_ref = sel1.PickObject(ot1, "Select a link instance first.")
link1 = doc.GetElement(li_ref.ElementId)
if isinstance(link1, RevitLinkInstance):
	tf1 = link1.GetTotalTransform()
	face_ref = sel1.PickObject(ot2, "Pick a face.")
	linkDoc = link1.GetLinkDocument()
	el1 = linkDoc.GetElement(face_ref.LinkedElementId)
	face_ref2 = face_ref.CreateReferenceInLink()
	sf0 = el1.GetGeometryObjectFromReference(face_ref2)
	if isinstance(el1, FamilyInstance):
		tf1 *= el1.GetTotalTransform()
	sf1 = sf0.Convert(face_ref2, tf1.ToCoordinateSystem(True) )
	for s in sf1:	
		s.Tags.AddTag("RevitFaceReference", face_ref)
	OUT = output1(sf1), face_ref.GlobalPoint.ToPoint(True), link1
else:
	tf1 = link1.GetTotalTransform()
	face_ref = sel1.PickObject(ot2, "Pick a face.")
	el1 = link1
	if isinstance(el1, FamilyInstance):
		tf1 *= el1.GetTotalTransform()
	sf0 = link1.GetGeometryObjectFromReference(face_ref)
	sf1 = sf0.Convert(face_ref, tf1.ToCoordinateSystem(True))
	OUT = output1(sf1), face_ref.GlobalPoint.ToPoint(True), link1

(Thanks dimitar for the awesome script btw) which gets the transformation of a element and use it as the basis of operation to rotate my view orthogonally to the plan i select… But it doesn’t work with “system types”, like walltypes, ceilings, etc… cause they don’t have the method “GetTotalTransform”, which i’m guessing by now only apply to model in-place elements… I looked throught the revitapidocs.com in search of a similar method for walltypes, but i can’t seen to find one.

This is my first try messing around with the API, so any help is very helpful

Transform, generally, is for family instances as their geometric characteristics are defined in a Family and transformed when instantiated in projects (said differently, Transform records how the geometry in a project document is different from what is created in the family document). I do not believe this applies to system families as their definition of location (or sketch), rotation, etc. is setup within the project document at the instance level.

1 Like

Hmmm, i get what you mean… So, do you think the orientation method is my way to go here?