
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi to all, i want create an add-in. In this add-in i must import a Points of Clouds. I know how to do with Revit (there is the button on "insert" menu, and after i must click on "3d View" for see my .rcp files on Revit) but i want to do with API. So..this is my code :
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
ref string message, ElementSet elements)
{
UIApplication uiApp = commandData.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = uiApp.Application;
Document doc = uiDoc.Document;
Transaction trans = new Transaction(doc, "ExComm");
trans.Start();
// Get the Revit library path as defined via the Options dialog - File Locations tab - Places button
string libraryPath = "";
app.GetLibraryPaths().TryGetValue("Imperial Library", out libraryPath);
if (String.IsNullOrEmpty(libraryPath))
{
libraryPath = "c:\\"; // If not have, use a default path.
}
// Allow the user to select a family file.
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = libraryPath;
openFileDialog1.Filter = "Family Files (*.rcp)|*.rcp";
// Load the family file using LoadFamily method and then give information.
if (DialogResult.OK == openFileDialog1.ShowDialog())
{
try
{
Autodesk.Revit.DB.Family family = null;
if (doc.LoadFamily(openFileDialog1.FileName, out family))
{
String name = family.Name;
TaskDialog.Show("Revit", "Family file has been loaded. Its name is " + name);
}
else
{
TaskDialog.Show("Revit", "Can't load the family file.");
}
}
catch (Exception ex)
{
TaskDialog.Show("Revit", ex.Message);
}
}
trans.Commit();
return Result.Succeeded;
}
But doc.LoadFamily always go on the else. What's i wrang? Sorry but i'm new on Revit Api World.
Thanks in advance
Nicola
Solved! Go to Solution.