public static PluginRecord ToPluginRecord(this ParsedRecord parsedRecord) { var projectDescriptor = new ProjectDescriptor(parsedRecord.ProjectPath); //var name = parsedRecord.PluginDescriptor.Name; //var manufacturer = parsedRecord.PluginDescriptor.Manufacturer; //var fullName = parsedRecord.PluginDescriptor.FullName; //var pluginDescriptor = new PluginDescriptor(name, manufacturer, fullName); var pluginRecord = new PluginRecord(parsedRecord.PluginDescriptor, projectDescriptor); return(pluginRecord); }
public AUFMLogin() { InitializeComponent(); userbox.Text = Settings.Default.Username; url.Text = Settings.Default.Url; PluginRecord pluginRecord = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("AUFMPlugin.AUFM"); dockPanePlugin = (AUFMDockPane)pluginRecord.LoadPlugin(); if (dockPanePlugin == null) { dockPanePlugin = new AUFMDockPane(); dockPanePlugin.ActivatePane(); } }
public JodsEngineGamePluginFormat() { Details = new PluginRecord() { Id = IdString, Name = "Jods Engine Game Format", Description = "asdf", Format = IntegratedPluginFormat.IdString, PackageId = "octgn.sdk", PackageVersion = "3.4.0.0", Path = "integrated", Type = "octgn.plugin" }; }
/// <summary> /// Launch /// </summary> public void LaunchPlugin() { // Running Navis if (Autodesk.Navisworks.Api.Application.IsAutomated) { throw new InvalidOperationException("Invalid when running using Automation"); } // Version if (!Autodesk.Navisworks.Api.Application.Version.RuntimeProductName.Contains("2014")) { MessageBox.Show("Incompatible Navisworks Version" + "\nThis Add-In was built for Navisworks 2014, please contact info@case-inc for assistance...", "Cannot Continue!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Find the plugin PluginRecord pr = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("ARUP.IssueTracker.Navisworks.Plugin.CASE"); if (pr != null && pr is DockPanePluginRecord && pr.IsEnabled) { /* * string m_issuetracker = Path.Combine(ProgramFilesx86(), "CASE", "ARUP Issue Tracker", "ARUP.IssueTracker.dll"); * if (!File.Exists(m_issuetracker)) * { * MessageBox.Show("Required Issue Tracker Library Not Found"); * return; * } * Assembly.LoadFrom(m_issuetracker); */ //check if it needs loading if (pr.LoadedPlugin == null) { string exeConfigPath = GetType().Assembly.Location; pr.LoadPlugin(); } DockPanePlugin dpp = pr.LoadedPlugin as DockPanePlugin; if (dpp != null) { //switch the Visible flag dpp.Visible = !dpp.Visible; } } }
public override int Execute(params string[] parameters) { PluginRecord pluginRecord = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("AUFMPlugin.AUFM"); AUFMDockPane dockPanePlugin = (AUFMDockPane)pluginRecord.LoadPlugin();; if (dockPanePlugin != null) { dockPanePlugin.toggleVisibilty(); } else { dockPanePlugin = new AUFMDockPane(); } return(0); }
public AUFMForm() { InitializeComponent(); PluginRecord pluginRecord = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("AUFMPlugin.AUFM"); dockPanePlugin = (AUFMDockPane)pluginRecord.LoadedPlugin; buildings = getBuildings(); comboBox1.Text = Settings.Default["Building"].ToString(); label2.Text = comboBox1.Text; button1.Click += new EventHandler(this.SelectBuilding); button2.Click += new EventHandler(this.uploadParts); comboBox1.TextChanged += new EventHandler(this.BuildingChanged); Autodesk.Navisworks.Api.Application.ActiveDocument.Models.CollectionChanged += fileChanged; populateComboBox(); updateButton(); getParts(); }
//load other plugin dynamically void LoadPluginDynamic() { //the name of the plugin which is to be loaded dynamically string plugin_name_to_load = "NWAPI_HelloWorldPlugin_AddInTab.ADSK"; // plugin record PluginRecord dotest = null; dotest = Autodesk.Navisworks.Api.Application.Plugins. FindPlugin(plugin_name_to_load); if (dotest != null) { // the plugin binary has been loaded. exit. MessageBox.Show("the plugin " + plugin_name_to_load + " has been loaded!"); } else { // load the plugin binary from full file path name Autodesk.Navisworks.Api.Application.Plugins.AddPluginAssembly( @"<Navisworks Install Path>\Lab-02.dll"); } // get the plugin record. PluginRecord otherpluginrecord = Autodesk.Navisworks.Api.Application.Plugins. FindPlugin(plugin_name_to_load); if (otherpluginrecord != null) { if (!otherpluginrecord.IsLoaded) { //if not loaded, load the plugin otherpluginrecord.LoadPlugin(); //get the plugin of the record Plugin otherplugin = otherpluginrecord.LoadedPlugin; //call one method of the plugin //since we do not know the type of the other plugin, //use InvokeMember string[] pa = { "dummy" }; otherplugin.GetType().InvokeMember("Execute", System.Reflection.BindingFlags.InvokeMethod, null, otherplugin, pa); } } }
public static void PluginSave(HttpContext context) { if (NBrightBuyUtils.CheckRights()) { var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context); var itemid = ajaxInfo.GetXmlProperty("genxml/hidden/itemid"); if (Utils.IsNumeric(itemid)) { var objCtrl = new NBrightBuyController(); var info = objCtrl.GetData(Convert.ToInt32(itemid)); var pluginRecord = new PluginRecord(info); var modelXml = Utils.UnCode(ajaxInfo.GetXmlProperty("genxml/hidden/xmlupdatemodeldata")); ajaxInfo.RemoveXmlNode("genxml/hidden/xmlupdatemodeldata"); pluginRecord.Info().XMLData = ajaxInfo.XMLData; // check for unique ctrl ref var ctrlref = pluginRecord.Info().GetXmlProperty("genxml/textbox/ctrl"); var ctrltest = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PLUGIN", ctrlref); if (ctrltest != null) { if (ctrltest.ItemID != pluginRecord.Info().ItemID) { pluginRecord.Info().SetXmlProperty("genxml/textbox/ctrl", pluginRecord.Info().GetXmlProperty("genxml/textbox/ctrl") + Utils.GetUniqueKey()); } } // make sure index is in correct format, (FLOAT) for SQL pluginRecord.Info().SetXmlProperty("genxml/hidden/index", (pluginRecord.Info().GetXmlPropertyInt("genxml/hidden/index").ToString()), TypeCode.Double); pluginRecord.Info().RemoveXmlNode("genxml/hidden/itemid"); pluginRecord.Info().RemoveXmlNode("genxml/hidden/editlanguage"); pluginRecord.Info().RemoveXmlNode("genxml/hidden/uilang1"); pluginRecord.Info().GUIDKey = pluginRecord.Info().GetXmlProperty("genxml/textbox/ctrl"); pluginRecord.UpdateModels(modelXml, Utils.GetCurrentCulture()); objCtrl.Update(pluginRecord.Info()); // remove save GetData cache DataCache.ClearCache(); //load entity typecode to DB idx settings. NBrightBuyUtils.RegisterEnityTypeToDataBase(); } } }
//int n = 0;//TEST public override int Execute(params string[] parameters) { //n = 0;//TEST Win.MessageBoxResult result = Win.MessageBox.Show("Начать выгрузку FBX по слоям?", "Выгрузка FBX", Win.MessageBoxButton.YesNo); if (result == Win.MessageBoxResult.Yes) { try { PluginRecord FBXPluginrecord = Application.Plugins. FindPlugin("NativeExportPluginAdaptor_LcFbxExporterPlugin_Export.Navisworks"); if (FBXPluginrecord != null) { if (!FBXPluginrecord.IsLoaded) { FBXPluginrecord.LoadPlugin(); } NativeExportPluginAdaptor FBXplugin = FBXPluginrecord.LoadedPlugin as NativeExportPluginAdaptor; Document doc = Application.ActiveDocument; string fbxPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string docPath = doc.FileName; if (!String.IsNullOrEmpty(docPath)) { fbxPath = Path.GetDirectoryName(docPath); } DocumentModels docModels = doc.Models; ModelItemEnumerableCollection rootItems = docModels.RootItems; ExportByLayers(rootItems, fbxPath, docModels, FBXplugin); Win.MessageBox.Show("Готово", "Готово", Win.MessageBoxButton.OK, Win.MessageBoxImage.Information); } } catch (Exception ex) { CommonException(ex, "Ошибка при экспорте в FBX по слоям"); } } return(0); }
public override int Execute(params string[] parameters) { //MessageBox.Show(Autodesk.Navisworks.Api.Application.Gui.MainWindow, "Chris Chen"); /* * FormNavisworks f = new FormNavisworks(); * * f.oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument; * f.Show(); */ try { //Find the plugin PluginRecord pr = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("ClassNavisRoomDFS.BIAD"); if (pr != null && pr is DockPanePluginRecord && pr.IsEnabled) { //check if it needs loading if (pr.LoadedPlugin == null) { pr.LoadPlugin(); } DockPanePlugin dpp = pr.LoadedPlugin as DockPanePlugin; if (dpp != null) { //switch the Visible flag dpp.Visible = !dpp.Visible; } } else { } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().Name); } return(0); }
public override int ExecuteCommand(string name, params string[] parameters) { switch (name) { case "ID_Button_1": if (!Autodesk.Navisworks.Api.Application.IsAutomated) { PluginRecord pluginRecord = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("ClDockPanelUpdate.AUTODOC"); if (pluginRecord is DockPanePluginRecord && pluginRecord.IsEnabled) { var dockPanel = (DockPanePlugin)(pluginRecord.LoadedPlugin ?? pluginRecord.LoadPlugin()); dockPanel.ActivatePane(); } } break; } return(0); }
/// <summary> /// Launch /// </summary> public void LaunchPlugin() { // Running Navis if (Autodesk.Navisworks.Api.Application.IsAutomated) { throw new InvalidOperationException("Invalid when running using Automation"); } // Version if (!Autodesk.Navisworks.Api.Application.Version.RuntimeProductName.Contains(NavisVersion)) { MessageBox.Show("Incompatible Navisworks Version" + "\nThis Add-In was built for Navisworks " + NavisVersion + ", please contact info@case-inc for assistance...", "Cannot Continue!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Find the plugin PluginRecord pr = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("Case.IssueTracker.Navisworks.Plugin.CASE"); if (pr != null && pr is DockPanePluginRecord && pr.IsEnabled) { string m_issuetracker = "Case.IssueTracker.dll"; //check if it needs loading if (pr.LoadedPlugin == null) { pr.LoadPlugin(); } DockPanePlugin dpp = pr.LoadedPlugin as DockPanePlugin; if (dpp != null) { //switch the Visible flag dpp.Visible = !dpp.Visible; } } }
public static void PluginAddInterface(HttpContext context) { try { if (NBrightBuyUtils.CheckRights()) { var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context); var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid"); if (Utils.IsNumeric(selecteditemid)) { var objCtrl = new NBrightBuyController(); var info = objCtrl.GetData(Convert.ToInt32(selecteditemid)); var pluginRecord = new PluginRecord(info); pluginRecord.AddInterface(); } } } catch (Exception ex) { // ignore } }
public static String PluginAddNew(HttpContext context) { try { if (NBrightBuyUtils.CheckRights()) { var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context); var strOut = ""; var themeFolder = ajaxInfo.GetXmlProperty("genxml/hidden/themefolder"); if (themeFolder == "") { themeFolder = "config"; } var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate"); var passSettings = NBrightBuyUtils.GetPassSettings(ajaxInfo); var info = new NBrightInfo(true); info.ItemID = -1; info.PortalId = PortalSettings.Current.PortalId; info.Lang = Utils.GetCurrentCulture(); info.SetXmlProperty("genxml/hidden/index", "99"); info.TypeCode = "PLUGIN"; info.GUIDKey = Utils.GetUniqueKey(12); var objCtrl = new NBrightBuyController(); info.ItemID = objCtrl.Update(info); var pluginRecord = new PluginRecord(info); strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", pluginRecord, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings); return(strOut); } return(""); } catch (Exception ex) { return(ex.ToString()); } }
/// <summary> /// Launch /// </summary> public void LaunchPlugin() { // Running Navis if (Autodesk.Navisworks.Api.Application.IsAutomated) { throw new InvalidOperationException("Invalid when running using Automation"); } // Version if (!Autodesk.Navisworks.Api.Application.Version.RuntimeProductName.Contains(NavisVersion)) { MessageBox.Show("This Add - In was built and tested only for Navisworks Manage " + NavisVersion + ", proceed at your own risk", "Untested Navisworks Version", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //Find the plugin PluginRecord pr = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("Bcfier.AppMain.Bcfier"); if (pr != null && pr is DockPanePluginRecord && pr.IsEnabled) { //string bcfier = "Bcfier.Navisworks.dll"; //check if it needs loading if (pr.LoadedPlugin == null) { pr.LoadPlugin(); } DockPanePlugin dpp = pr.LoadedPlugin as DockPanePlugin; if (dpp != null) { //switch the Visible flag dpp.Visible = !dpp.Visible; } } }
/// <summary> /// Launch Main Command /// </summary> public void LaunchNavis2Bcf() { // Don't Support Automation if (Autodesk.Navisworks.Api.Application.IsAutomated) { throw new InvalidOperationException("Invalid when running using Automation"); } //Find the plugin PluginRecord m_pr = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("Navis2BCF.Plugin.CASE"); if (m_pr != null && m_pr is DockPanePluginRecord && m_pr.IsEnabled) { //need to load the assebly from here otherwise navis will crash! string m_dllfolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Ionic.Zip.dll"); if (!File.Exists(m_dllfolder)) { MessageBox.Show("Required Ionic Library Not Found"); return; } Assembly.LoadFrom(m_dllfolder); // check if it needs loading if (m_pr.LoadedPlugin == null) { string exeConfigPath = this.GetType().Assembly.Location; m_pr.LoadPlugin(); } DockPanePlugin m_dpp = m_pr.LoadedPlugin as DockPanePlugin; if (m_dpp != null) { // switch the Visible flag m_dpp.Visible = !m_dpp.Visible; } } }
public override int Execute(params string[] parameters) { if (Autodesk.Navisworks.Api.Application.IsAutomated) { throw new InvalidOperationException("Invalid when running using Automation"); } //try { // //Find the plugin PluginRecord pr = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("NW_GraphicPrograming.NW_GP_Dock.PRD"); if (pr != null && pr is DockPanePluginRecord && pr.IsEnabled) { //check if it needs loading if (pr.LoadedPlugin == null) { pr.LoadPlugin(); } DockPanePlugin dpp = pr.LoadedPlugin as DockPanePlugin; if (dpp != null) { //switch the Visible flag dpp.Visible = !dpp.Visible; } } //} //catch //{ // MessageBox.Show("Error"); //} return(0); }
public override int Execute(params string[] parameters) { // Starting new code for DockPanePlugin // Find the plugin first using its pluginId PluginRecord pr = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("MTechProject.LoadDockPane.SYPN"); if (pr != null && pr is DockPanePluginRecord && pr.IsEnabled) { //The plugin might need to be loaded into the system if (pr.LoadedPlugin == null) { pr.LoadPlugin(); } //The plugin need to be casted into a more specific type DockPanePlugin dpp = pr.LoadedPlugin as DockPanePlugin; if (dpp != null) { dpp.Visible = !dpp.Visible; } } //End of new code for DockPanePlugin return(0); }
public static String PluginAdminDetail(HttpContext context) { try { if (NBrightBuyUtils.CheckRights()) { var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context); var strOut = ""; var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid"); if (Utils.IsNumeric(selecteditemid)) { var themeFolder = ajaxInfo.GetXmlProperty("genxml/hidden/themefolder"); if (themeFolder == "") { themeFolder = "config"; } var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate"); var passSettings = NBrightBuyUtils.GetPassSettings(ajaxInfo); var objCtrl = new NBrightBuyController(); var info = objCtrl.GetData(Convert.ToInt32(selecteditemid)); var pluginRecord = new PluginRecord(info); strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", pluginRecord, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings); } return(strOut); } return(""); } catch (Exception ex) { return(ex.ToString()); } }
private void LoadModule(string pluginPath) { Type objType; Assembly assemblyObj; var fileName = Path.GetFileNameWithoutExtension(pluginPath); if ((assemblyObj = Assembly.LoadFrom(pluginPath)) == null) { return; } var pluginName = $"Minary.Plugin.Main.{fileName}"; objType = assemblyObj.GetType(pluginName, false, false); if (objType == null) { return; } var pluginProperties = new PluginProperties() { ApplicationBaseDir = Directory.GetCurrentDirectory(), PluginBaseDir = pluginPath, PatternSubDir = string.Empty, HostApplication = (IPluginHost)this }; /* * Add loaded plugin to ... * - the global "plugin list" (IPlugin) * - the "used plugins DGV" list * - the "plugin position" list (name + position) */ object tmpPluginObj = Activator.CreateInstance(objType, pluginProperties); if ((tmpPluginObj is IPlugin) == false || (tmpPluginObj is UserControl) == false) { return; } try { var tmpPluginRec = new PluginRecord(); tmpPluginRec.IPlugin = (IPlugin)tmpPluginObj; tmpPluginRec.UserControl = (UserControl)tmpPluginObj; tmpPluginRec.TabPage = new TabPage(tmpPluginRec.IPlugin.Config.PluginName); this.pluginDict.Add(tmpPluginRec.IPlugin.Config.PluginName, tmpPluginRec); // Initialize new tab page ... tmpPluginRec.TabPage.Controls.Add(tmpPluginRec.IPlugin.PluginControl); tmpPluginRec.TabPage.ImageIndex = (int)Status.NotRunning; tmpPluginRec.TabPage.BorderStyle = BorderStyle.None; // Let the plugin user control adapt its size when parent control (the tab control) resizes. tmpPluginRec.UserControl.Dock = DockStyle.Fill; // //this.tp_Plugin = newPluginTabPage; this.loadedPlugin = tmpPluginRec.IPlugin; this.LogMessage($"Plugin {loadedPlugin.Config.PluginName} loaded"); this.tb_PluginPath.Text = pluginPath; this.TC_PluginTester.Controls.Add(tmpPluginRec.TabPage); //this.tp_Plugin.Refresh(); //this.TC_PluginTester.Refresh(); //this.Refresh(); // Initialize and register the plugin. this.loadedPlugin.OnInit(); } catch (ArgumentNullException ex) { MessageBox.Show($"ArgumentNullException {fileName}: {ex.Message} {ex.StackTrace}"); } catch (ArgumentException ex) { MessageBox.Show($"ArgumentException {fileName}: {ex.Message} {ex.StackTrace}"); } catch (NotSupportedException ex) { MessageBox.Show($"NotSupportedException {fileName}: {ex.Message} {ex.StackTrace}"); } catch (TargetInvocationException ex) { if (ex.InnerException != null) { MessageBox.Show($"TargetInvocationException {fileName}: {ex.Message} - {ex.InnerException.Message}"); } else { MessageBox.Show($"TargetInvocationException {fileName}: {ex.Message} {ex.StackTrace}"); } } catch (MethodAccessException ex) { MessageBox.Show($"MethodAccessException {fileName}: {ex.Message} {ex.StackTrace}"); } catch (MemberAccessException ex) { MessageBox.Show($"MemberAccessException {fileName}: {ex.Message} {ex.StackTrace}"); } catch (TypeLoadException ex) { MessageBox.Show($"TypeLoadException {fileName}: {ex.Message} {ex.StackTrace}"); } catch (Exception ex) { MessageBox.Show($"Exception {fileName}: {ex.Message} {ex.StackTrace}"); } }
public override int Execute(params string[] parameters) { Win.MessageBoxResult result = Win.MessageBox.Show("Перед экспортом FBX, нужно скрыть те элементы модели, которые не нужно экспортировать. " + "А так же нужно настроить параметры экспорта в FBX на экспорт в формате ASCII" + "\n\nНачать выгрузку FBX?", "Выгрузка FBX", Win.MessageBoxButton.YesNo); if (result == Win.MessageBoxResult.Yes) { try { //ComApi.InwOpState3 oState = ComApiBridge.ComApiBridge.State; PluginRecord FBXPluginrecord = Application.Plugins. FindPlugin("NativeExportPluginAdaptor_LcFbxExporterPlugin_Export.Navisworks"); if (FBXPluginrecord != null) { if (!FBXPluginrecord.IsLoaded) { FBXPluginrecord.LoadPlugin(); } NativeExportPluginAdaptor FBXplugin = FBXPluginrecord.LoadedPlugin as NativeExportPluginAdaptor; Document doc = Application.ActiveDocument; string fbxPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string docPath = doc.FileName; string defFBXFileName = ""; if (!String.IsNullOrEmpty(docPath)) { fbxPath = Path.GetDirectoryName(docPath); defFBXFileName = Path.GetFileNameWithoutExtension(docPath) + ".fbx"; } //Указание пользователем имени файла для fbx WinForms.SaveFileDialog sFD = new WinForms.SaveFileDialog(); sFD.InitialDirectory = fbxPath; sFD.Filter = "fbx files (*.fbx)|*.fbx"; sFD.FilterIndex = 1; sFD.RestoreDirectory = true; if (!String.IsNullOrWhiteSpace(defFBXFileName)) { sFD.FileName = defFBXFileName; } sFD.Title = "Укажите файл для записи fbx"; if (sFD.ShowDialog() == WinForms.DialogResult.OK) { //Выполнить экспорт в FBX if (0 == FBXplugin.Execute(sFD.FileName)) { if (IsASCIIFBXFile(sFD.FileName)) { DocumentModels docModels = doc.Models; ModelItemEnumerableCollection rootItems = docModels.RootItems; string editedFBXFileName = Common.Utils .GetNonExistentFileName(Path.GetDirectoryName(sFD.FileName), Path.GetFileNameWithoutExtension(sFD.FileName) + "_Edited", "fbx"); fBXCurrObjLine = null; using (StreamWriter sw = new StreamWriter(editedFBXFileName)) { using (StreamReader sr = new StreamReader(sFD.FileName)) { OverwriteFBX(rootItems, sw, sr, false); //Дописать FBX до конца sw.Write(sr.ReadToEnd()); } } Win.MessageBox.Show("Готово", "Готово", Win.MessageBoxButton.OK, Win.MessageBoxImage.Information); } else { //FBX не ASCII throw new Exception("FBX не в формате ASCII"); } } else { //Ошибки при экспорте throw new Exception("Возникли ошибки при экспорте FBX"); } } } } catch (Exception ex) { CommonException(ex, "Ошибка при экспорте в FBX"); } } return(0); }
public override int Execute(params string[] parameters) { Win.MessageBoxResult result = Win.MessageBoxResult.Yes; if (ManualUse) { result = Win.MessageBox.Show("Перед экспортом FBX, нужно скрыть те элементы модели, которые не нужно экспортировать. " + "А так же нужно настроить параметры экспорта в FBX на экспорт ЛИБО В ФОРМАТЕ ASCII, ЛИБО В ДВОИЧНОМ ФОРМАТЕ ВЕРСИИ НЕ НОВЕЕ 2018. " + "Рекомендуется так же отключить экспорт источников света и камер. " + "\n\nНачать выгрузку FBX?", "Выгрузка FBX", Win.MessageBoxButton.YesNo); } if (result == Win.MessageBoxResult.Yes) { try { PluginRecord FBXPluginrecord = Application.Plugins. FindPlugin("NativeExportPluginAdaptor_LcFbxExporterPlugin_Export.Navisworks"); if (FBXPluginrecord != null) { if (!FBXPluginrecord.IsLoaded) { FBXPluginrecord.LoadPlugin(); } NativeExportPluginAdaptor FBXplugin = FBXPluginrecord.LoadedPlugin as NativeExportPluginAdaptor; Document doc = Application.ActiveDocument; string fbxPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string docPath = doc.FileName; string defFBXFileName = ""; if (!String.IsNullOrEmpty(docPath)) { fbxPath = Path.GetDirectoryName(docPath); defFBXFileName = Path.GetFileNameWithoutExtension(docPath) + ".fbx"; } //Указание пользователем имени файла для fbx string fbxFullFileName = null; if (ManualUse) { WinForms.SaveFileDialog sFD = new WinForms.SaveFileDialog(); sFD.InitialDirectory = fbxPath; sFD.Filter = "fbx files (*.fbx)|*.fbx"; sFD.FilterIndex = 1; sFD.RestoreDirectory = true; if (!String.IsNullOrWhiteSpace(defFBXFileName)) { sFD.FileName = defFBXFileName; } sFD.Title = "Укажите файл для записи fbx"; if (sFD.ShowDialog() == WinForms.DialogResult.OK) { fbxFullFileName = sFD.FileName; } } else { fbxFullFileName = FBXSavePath; FileAttributes attr = File.GetAttributes(fbxFullFileName); if (attr.HasFlag(FileAttributes.Directory)) { //добавить имя файла fbxFullFileName = Path.Combine(fbxFullFileName, FBXFileName); } } if (!String.IsNullOrEmpty(fbxFullFileName)) { string notEditedDirectory = Path.Combine(Path.GetDirectoryName(fbxFullFileName), "NotEdited"); if (!Directory.Exists(notEditedDirectory)) { Directory.CreateDirectory(notEditedDirectory); } string notEditedFileName = Path.Combine(notEditedDirectory, Path.GetFileName(fbxFullFileName)); if (ManualUse) { BusyIndicatorHelper.ShowBusyIndicator(); BusyIndicatorHelper.SetMessage("Стандартный экспорт FBX"); } if (FBXplugin.Execute(notEditedFileName) == 0)//Выполнить экспорт в FBX { if (ManualUse) { BusyIndicatorHelper.SetMessage("Редактирование FBX"); } bool isASCII = IsASCIIFBXFile(notEditedFileName); if (isASCII || GetBinaryVersionNum(notEditedFileName) <= 7500) { //Прочитать модель, составить очередь имен для подстановки в FBX Queue <FBX.NameReplacement> replacements = new Queue <FBX.NameReplacement>(); DocumentModels docModels = doc.Models; ModelItemEnumerableCollection rootItems = docModels.RootItems; //if (rootItems.Count() > 1) //{ // //Если в Navis несколько корневых узлов (как в nwf), // //то один узел в самом начале FBX должен быть пропущен // //Там появится узел Environment // replacements.Enqueue(new FBX.NameReplacement()); //} ComApi.InwOpState3 oState = ComApiBridge.ComApiBridge.State; NameReplacementQueue(rootItems, replacements, oState); if (rootItems.Count() == 1) { //Обозначить, что первый узел имеет ненадежное имя. //В FBX оно всегда - Environment, а в Navis - имя открытого файла //replacements.Peek().OldNameTrustable = false; //Если корневой узел один, то убрать его из списка. Его не будет в FBX replacements.Dequeue(); } //Первый узел в списке замены должен обязательно иметь верное имя //(в начале списка могут быть с пустым значением, которые отключены в Navis) while (!replacements.Peek().OldNameTrustable) { replacements.Dequeue(); } //Отредактировать FBX FBX.ModelNamesEditor fbxEditor = null; if (IsASCIIFBXFile(notEditedFileName)) { fbxEditor = new FBX.ASCIIModelNamesEditor(notEditedFileName, replacements); } else /*if (GetBinaryVersionNum(sFD.FileName) <= 7500)*/ { fbxEditor = new FBX.BinaryModelNamesEditor(notEditedFileName, replacements); } fbxEditor.FbxFileNameEdited = fbxFullFileName; fbxEditor.EditModelNames(); if (ManualUse) { BusyIndicatorHelper.CloseBusyIndicator(); Win.MessageBox.Show("Файл FBX с отредактированными именами моделей - " + fbxEditor.FbxFileNameEdited, "Готово", Win.MessageBoxButton.OK, Win.MessageBoxImage.Information); } } else { throw new Exception("Неподдерживаемый формат FBX"); } } else { throw new Exception("При экспорте FBX из NavisWorks произошли ошибки"); } if (ManualUse) { //на всякий случай BusyIndicatorHelper.CloseBusyIndicator(); } } } } catch (Exception ex) { CommonException(ex, "Ошибка при экспорте в FBX из Navis"); } } return(0); }