Adaptive Component Creation

Here is some code that shows how to place adaptive components. In this case, the adaptive component contains 2 placement points. I wrote this to examine the shape of an element’s bounding box – you may find other uses for it.

bboxpublic void bbox()
{
    UIDocument uidoc = this.ActiveUIDocument;
    Document doc = uidoc.Document;   
    
    // select an element
    Element element = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element));
    
    // get bounding box of the element
    BoundingBoxXYZ bbox = element.get_BoundingBox(null);
    
    // get adaptive component family instance
    FamilySymbol fs = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast<FamilySymbol>().First(q => q.Name == "Type 1" && q.Family.Name == "TwoPoint");
    
    // create instances of the adaptive component
    placeInstance(fs, bbox.Min, bbox.Max, "Space Diagonal");
    placeInstance(fs, bbox.Min, new XYZ(bbox.Max.X, bbox.Max.Y, bbox.Min.Z), "Base diagonal");
    placeInstance(fs, bbox.Min, new XYZ(bbox.Max.X, bbox.Min.Y, bbox.Min.Z), "vx");
    placeInstance(fs, bbox.Min, new XYZ(bbox.Min.X, bbox.Max.Y, bbox.Min.Z), "vy");
    placeInstance(fs, bbox.Min, new XYZ(bbox.Min.X, bbox.Min.Y, bbox.Max.Z), "vz");
}

// create a new instance of the family & set the location of endpoints and Comments parameter
private void placeInstance (FamilySymbol fs, XYZ xyz1, XYZ xyz2, string comment)
{
    Document doc = fs.Document;
    using (Transaction t = new Transaction(doc,"adaptive component"))
    {
        t.Start();
        // place the adaptive component - adaptive points are automatically given some default position during creation
        FamilyInstance fi = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(doc, fs);
        
        // get references to the adaptive points in the newly created instance
        IList<FamilyPointPlacementReference> refs = fi.GetFamilyPointPlacementReferences();        
        
        // adaptive component points are named "start" and "end"
        // move these points to the input XYZ locations xyz1 and xyz2 
        movePoint(doc, refs.First(q => q.Name == "start"), xyz1);
        movePoint(doc, refs.First(q => q.Name == "end"), xyz2);
        
        // get Comments parameter and set its value
        fi.get_Parameter("Comments").Set(comment);
        t.Commit();
    }
}

// move an FamilyPointPlacementReference to a specified XYZ
private void movePoint(Document doc, FamilyPointPlacementReference point, XYZ xyz)
{
    // need to subtract the default XYZ location of the point from the desired XYZ location
    ElementTransformUtils.MoveElement(doc, point.PointReference.ElementId, xyz.Subtract(locationFromPoint(doc, point)));
}

// get the XYZ location of a FamilyPointPlacementReference
private XYZ locationFromPoint(Document doc, FamilyPointPlacementReference point)
{
    Element e = doc.GetElement(point.PointReference.ElementId);
    ReferencePoint rp = e as ReferencePoint;
    return rp.Position;
}

Download your free trial of the Revit File Logger

The File Logger described last week is now available for download at http://gdurl.com/QrR8/download

Specify the full path to the log file in FileOpenLog.ini in the folder C:\ProgramData\Autodesk\Revit\Addins\<version #>\BoostYourBIM-FileOpenLog
This free trial provides data for all files <50MB. To purchase a full version, contact boostyourbim@gmail.com

Computer name and drive free space have been added, so the complete list of fields collected is:

  1. Open Started Time
  2. Open Completed Time
  3. Elapsed Time (HH:MM:SS)
  4. User Name
  5. File Name
  6. File Size (MB)
  7. Path to Central File
  8. File Last Saved Revit Version
  9. Saved in Current Version (Y/N)
  10. Revit Version Name of current session
  11. Revit Version # of current session
  12. Revit Build # of current session
  13. Computer name
  14. Computer free space on drive containing the Revit file

Sample Data:
Untitled

File Version check enhancements

Thanks for all the positive & constructive feedback on the Version Check tool. Here is a new version with several enhancements:

http://gdurl.com/lbnw/download

  1. Performance enhancements
  2. Cancellable dialog while the tool searches for Revit files
  3. Report includes columns of the following additional data for each file
    1. Size in MB
    2. Last modified date
    3. Last version # (in case you don’t care about the difference between “Revit Architecture 2014”, “Revit MEP 2014”, and “Revit 2014”)
    4. File type (rvt, rfa, rft, rte)
  4. Option to skip backup files
  5. Name of the Excel file contains a date/time stamp so you don’t need to close a previous report before running a new report

Enjoy!

Logging data when opening Revit files

Here’s a prototype of a new tool to track data about your Revit files, who opens them, how long the open takes, if they need to be upgraded, and more. Please leave a comment if you like this or have ideas about how to make it better.

Data Collected:

Open Started Open Completed Elapsed (HH:MM:SS) User File Name File Size (MB) Central File File Last Saved Version Saved in Current Version Revit Version Name Revit Version # Revit Build #

Sample Data:
Untitled Open times are rounded down to the nearest second.

File Version Check – now with the ability to search all subfolders

Thanks to everyone who has mentioned how much they like the File Version Check tool. I’ve added the ability to generate a report on an entire folder & all of its subfolders. The output is also now written to an Excel file instead of a CSV file.

Download it at http://gdurl.com/lbnw/download

Version Check subfolders

With this I was able to run a report on the 13,375 Revit files in C:\ProgramData\Autodesk and generate the report excerpted below.

VersionCheckReport

Thanks to “Revit Add-Ons” for an Editor’s Choice award!

Free File Version Reporter Add-in for Revit: Finally, Get a “Do You Want to Upgrade” Alert!

“Would you like Revit to ask you if you want to upgrade files rather then the program just doing it? If so, the free File Version Reporter add-in from Boost Your BIM is for you!”