How do I use the Revit API to read ITM files?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create a Revit Add-In that will read ITM files using the Revit API and/or the Fabrication API. The Autodesk Fabrication API contains samples to do this, but when I try to use the same process I am running into a System.AccessViolationException on the line where I try to set the item. Does anyone know how to get around this exception, or what is causing it? Or, is there a way to read ITM files using just the Revit API, and not the Fabrication API?
I have tried multiple different ITM files, so I do not think that the file itself is the problem.
My code:
public static string QueryDatabaseServices()
{
System.Reflection.Assembly.LoadFrom(@"C:\Program Files\Autodesk\Fabrication 2018\CADmep\FabricationAPI.dll");
StringBuilder builder = new StringBuilder();
Autodesk.Fabrication.Item itm1 = null;
itm1 = Autodesk.Fabrication.Content.ContentManager.LoadItem(@"**file path of ITM file**");
builder.AppendLine(itm1.Name);
builder.AppendLine(itm1.CID.ToString());
builder.AppendLine(itm1.Description);
return builder.ToString();
}
I am calling this function from my Revit Add-In, which launches and works fine.