Hi @DeanLyon2 ,
Sorry for the delay.
I tested your application. I have no clue what is causing the issue in your application.
I created my own console application and copy-pasted the sample code which is present in your application. My console application is working fine.
I would suggest you create a new project and test it.
Here are the steps I followed
1)I created a console application.
2)I added the required dlls to my console visual studio project(NW Simulate 2022).
3)I set "Autodesk.Navisworks.Resolver" copy the local value to "True".For other dlls, I set copy the local value to "False"
4) Right-click your project in solution explorer--> Properties --> Build -->Platform target-->Set "x64"
5)Now everything worked fine for me.
Here is the sample code I used
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.ApplicationParts;
using Autodesk.Navisworks.Api.Controls;
using Autodesk.Navisworks.Api.DocumentParts;
using Autodesk.Navisworks.Api.Plugins;
using Autodesk.Navisworks.Api.Resolver;
using Autodesk.Navisworks.Api.Data;
namespace Simple_Console
{
class Program
{
[STAThread]
static void Main(string[] args)
{
//BuildModel cmb = new BuildModel();
String runtimeName = Resolver.TryBindToRuntime(RuntimeNames.NavisworksSimulate);
if (String.IsNullOrEmpty(runtimeName)) { throw new Exception("Failed to bind to Navisworks runtime"); }
//cmb.BuildCompositeModel(PlantCode, RemoveList, IncludeList);
//cmb = null;
try
{
XMain(args);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
private static void XMain(string[] args)
{
List<Model> ModelList = new List<Model>();
Autodesk.Navisworks.Api.Automation.NavisworksApplication oApp = null;
Autodesk.Navisworks.Api.Controls.ApplicationControl.ApplicationType = ApplicationType.SingleDocument;
Autodesk.Navisworks.Api.Application.FileInteractiveResolving += Application_FileInteractiveResolving;
Autodesk.Navisworks.Api.Application.FileResolving += Application_FileResolving;
ApplicationControl.Initialize();
DocumentControl documentCtrl = new DocumentControl();
documentCtrl.SetAsMainDocument();
Console.WriteLine("End");
Console.ReadKey();
}
private static void Application_FileResolving(object sender, FileResolvingEventArgs e)
{
e.Handled = true;
}
private static void Application_FileInteractiveResolving(object sender, FileInteractiveResolvingEventArgs e)
{
e.Handled = true;
}
}
}
Naveen Kumar T
Developer Technical Services
Autodesk Developer Network