Message 1 of 4
Error in REVITAPIUI version
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I have the following WPF application that selects the pipes in a Revit project.
<Window x:Class="WpfApp2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button Content="Button" Click="OpenModelButton_Click"/>
<Button Content="Button" Click="SelectPipesButton_Click"/>
</Grid>
</Window>
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection.Metadata;
using System.Transactions;
using System.Windows;
using System.Xml.Linq;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
namespace WpfApp2
{
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class MyExternalCommand : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
Reference pickedObj = uidoc.Selection.PickObject(ObjectType.Element, "Select element");
ElementId id = pickedObj.ElementId;
using (Transaction tx = new Transaction(doc))
{
tx.Start("IdentifyTrechoTransaction");
if (pickedObj != null)
{
Element element = doc.GetElement(id);
Parameter trechoParameter = element.get_Parameter(BuiltInParameter.ALL_MODEL_MARK);
trechoParameter.Set("Funcionouuuuuuu");
}
tx.Commit();
}
return Result.Succeeded;
}
}
public partial class MainWindow : Window
{
private const string RevitPath = @"C:\Program Files\Autodesk\Revit 2024\Revit.exe";
private const string ModelPath = @"D:\Revit Arquivos\Modelo Hidrante 2024.rvt";
public MainWindow()
{
InitializeComponent();
}
private void OpenModelButton_Click(object sender, RoutedEventArgs e)
{
if (File.Exists(RevitPath))
{
if (File.Exists(ModelPath))
{
Process.Start(RevitPath, $"\"{ModelPath}\"");
}
else
{
MessageBox.Show("Arquivo do modelo não encontrado.");
}
}
else
{
MessageBox.Show("Caminho do Revit inválido.");
}
}
private void SelectPipesButton_Click(object sender, RoutedEventArgs e)
{
MyExternalCommand externalCommand = new MyExternalCommand();
string message = string.Empty;
ElementSet elements = new ElementSet();
Result result = externalCommand.Execute(null, ref message, elements);
if (result != Result.Succeeded)
{
MessageBox.Show("Erro ao executar o comando externo.");
}
}
}
}
The above code is displaying the following error:
System.IO.FileNotFoundException: 'Could not load file or assembly 'RevitAPIUI, Version=24.0.0.0, Culture=neutral, PublicKeyToken=null'. O sistema não pode encontrar o arquivo especificado.'
I have revitapiui.dll version 24.0.4.427
How can I resolve this issue?