The client needs a Synchro 4D animation of his building do to detect possible issues in constructions and also a video to show to the rest of the stakeholders.
Synchro4D is a software for 4D visualization and construction coordination.It allows you to animate and program any 3D object exported from Autodad, Revit, Infraworks, sketchup, etc.
|
Not related with post but not less true... |
The only input I have right now is a federated navisworks model and a mpp - Ms Project - file with tasks and a Gantt diagram.
Synchro (as Navisworks) has the ability of read any parameter on the Revit model and relate it to the right task from the project.*
In order to save time while waiting for Revit models I had the idea of creating a Selection Set per task containing Model items related to each one. This Selection Sets will be named after the task's name.
|
Category's Scheme to work with. |
The only thing left to do is export a csv file with the sets' content, displaying set's name, source of the file (revit's file name where were exported) and element's Id .
The file should look like this:
SelectionSet,SourceName,ElementId
This can be achieved using the Navisworks API to access all the sets, and then all elements on each one.
Here is the code I've used. You may want to test it using the add-in CodeRun include with Naviswork's API.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.DocumentParts;
using System.IO;
namespace CScript
{
public class CScript
{
static public void Main()
{
var csv = new StringBuilder();
var output = new List<String>();
Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument;
//All selection sets in model
Autodesk.Navisworks.Api.DocumentParts.DocumentSelectionSets oCurSets = oDoc.SelectionSets;
//Convert to SavedItemCollectin
SavedItemCollection coll = oCurSets.ToSavedItemCollection();
//Path of the current file to save our csv later
var path = (oDoc.CurrentFileName).Replace(oDoc.Title, "");
//Iterate over all selections sets to create a current selection
foreach (SavedItem i in coll)
{
//Create a selection source with all objects in selection
SelectionSource oS = Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.CreateSelectionSource(i);
//Get a list of ModelItems in Selection Set
ModelItemCollection list = oS.TryGetSelectedItems(oDoc);
Selection a = new Selection(list);
var set = i.DisplayName;
Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.AddRange(list);
foreach (ModelItem m in oDoc.CurrentSelection.SelectedItems)
{
var Name = m.DisplayName;
var FC = m.PropertyCategories.FindPropertyByDisplayName("Item", "Source File").Value.ToDisplayString();
var SC = m.PropertyCategories.FindPropertyByDisplayName("Element ID", "Value").Value.ToDisplayString();
var newLine = string.Format("{0},{1},{2},{3}", set, Name, FC, SC);
output.Add(newLine);
csv.AppendLine(newLine);
}
Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Clear();
}
//Check if document is saved and use its path to save the csv
if (oDoc.FileName != null)
{
File.WriteAllText(path + oDoc.Title + ".csv", csv.ToString());
}
else
{
//if file is not saved (untitled) use MyDocuments path instade
path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
File.WriteAllText(path + oDoc.Title + ".csv", csv.ToString());
}
//test
foreach (string s in output)
{
Console.WriteLine(s);
}
}
}
}
Notice it will export the csv file to the same folder of the NWD or NWF, if the file was not saved it will be saved in MyDocuments.
Later we will input this information to each Revit model using Dynamo and then export it to Synchro4D.
Hope you find it useful! Let me know if you have any ideas to share or a different workflow to work with.
*We don't use Navisworks for this work because Synchro4D has a better platform to animate the actions on each thask - Demo, Temporary, New construction - and the final outcome needs to show how it actually has to be built.