Hi Paul - With the help you gave me in another thread
viewtopic.php?f=76&t=51654&p=257713#p257713 and with the help of an intern who is good at coding I was able to put together some Python code to output a CSV file for all the instances of a selected family. I haven't put the latest information you provided about the rotation into the code (although I tried it manually with an excel file and it worked really well) but am really stumped on how to access the rotation of the families.
I've spent a lot of time searching around but since I'm not a programmer (just an architect) I don't really understand how to take the example you gave of randomly rotating instances and reversing it to identify all the rotations of families that are placed.
Can you help me with the missing parts? I think this would be really valuable to all the Revit for Octane users out there who want to place cars, trees, furniture etc. on topo or flat surfaces while staying inside the Revit interface. I use PhantomScatter for all of the area scatters but it doesn't work well (currently) in the per-tri method with any type of extruded surface (which all families have). It also is a generic interface that does a lot more than most of our in-house architects need. Putting this code into a Revit Macro would make life so much easier for our guys.
I understand if you don't want to do this as it's a custom piece of software and not really part of the Octane engine. If you can't then maybe someone else reading this can.
The stuff you've put together so far into the interface has been wonderful, it's all greatly appreciated.
As always, thanks
Ed
import clr
import System
import csv
# These imports give access to the Revit API
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
app = __revit__.Application
doc = uidoc.Document
# 'uidoc' is the pre-define Revit API varible (uidoc = __revit__.ActiveUIDocument)
# These two lines set the active Revit/Vasari application and document for use
# Get the currently selected instance of a family
selectedInstance = uidoc.Selection.Elements
if selectedInstance.Size != 1:
print "Error: A single family instance must be selected"
else:
for item in selectedInstance:
currentElement = item
print "Current Selection = " + currentElement.Name
ofile_address = "C:/scatter_files/" + currentElement.Name + "_scatter.csv"
ofile = open(ofile_address, 'wb')
# creates output file to write to based on family name
writer = csv.writer(ofile, dialect= 'excel', delimiter=",")
# creates csv.writer object
# writer for testing purposes
testFile = open("C://scatter_files/matrixTest.csv", 'wb')
testWriter = csv.writer(testFile, dialect = 'excel', delimiter = ",")
NonCSVTest = open("C://scatter_files/OtherTest.txt",'w')
# create a collector for elements
collector = FilteredElementCollector(doc)
collector.OfClass(FamilyInstance)
famtypeitr = collector.GetElementIdIterator()
famtypeitr.Reset()
count = 0
for item in famtypeitr:
famtypeID = item
faminst = doc.GetElement(famtypeID)
if faminst.Name == currentElement.Name:
# Retrieve the point location of the family instance
p1 = faminst.Location.Point;
# need a way to find displacement from axis, scaling, and rotation
# get geometry of family instance
elementGeometry = faminst.get_Geometry
# get transform of family instance
elementTransform = faminst.GetTransform()
print str(elementTransform)
#testWriter.writerow(elementTransform)
#testWriter.writerow(elementGeometry)
NonCSVTest.write(str(elementTransform) + "test")
matrix = [0, 0.0, 0.0, p1.X, 0.0, 0.0, 0.0, p1.Y, 0.0, 0.0, 0.0, p1.Z]
writer.writerow(matrix)
# write the new matrix to the csv file
# this creates a row of 12 floats in for each family instance
count += 1
print "Saved " + str(count) + " family instances of " + currentElement.Name
ofile.close()
testFile.close()