Skip to content

Commit 46ad826

Browse files
committed
update setting copy run in nw 2022
1 parent a71fc59 commit 46ad826

File tree

6 files changed

+61
-42
lines changed

6 files changed

+61
-42
lines changed

NavisPythonShell/NavisPythonShell.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@
277277
</PreBuildEvent>
278278
</PropertyGroup>
279279
<PropertyGroup>
280-
<PostBuildEvent>if not exist "C:\Program Files\Autodesk\Navisworks Manage 2022\Plugins\NavisPythonShell\" mkdir "C:\Program Files\Autodesk\Navisworks Manage 2022\Plugins\NavisPythonShell\"
281-
xcopy $(TargetDir)*.* "C:\Program Files\Autodesk\Navisworks Manage 2022\Plugins\NavisPythonShell\" /Y /I /E</PostBuildEvent>
280+
<PostBuildEvent>xcopy $(TargetDir)*.* "C:\Program Files\Autodesk\Navisworks Manage 2022\Plugins\NavisPythonShell\" /Y /I /E /EXCLUDE:$(SolutionDir)exclude.txt
281+
xcopy $(TargetDir)*.* "C:\Program Files\Autodesk\Navisworks Manage 2022\Dependencies\" /Y /I /E /EXCLUDE:$(SolutionDir)noexclude.txt</PostBuildEvent>
282282
</PropertyGroup>
283283
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
284284
Other similar extension points exist, see Microsoft.Common.targets.

NavisPythonShell/NavisPythonShellApplication.cs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,18 @@ public static void OnLoaded()
2727
{
2828
try
2929
{
30-
applicationLoaded = true;
31-
var dllfolder = GetSettingsFolder();
32-
settingsFolder = dllfolder;
33-
34-
var settings = GetSettings();
35-
30+
applicationLoaded = true;
31+
var dllfolder = GetSettingsFolder();
32+
settingsFolder = dllfolder;
33+
34+
var settings = GetSettings();
35+
3636
//var assemblyName = "CommandLoaderAssembly";
3737
//var dllfullpath = Path.Combine(dllfolder, assemblyName + ".dll");
3838
//CreateCommandLoaderAssembly(settings, dllfolder, assemblyName);
39+
//seems like I need to pre-load my dependencies
40+
AppDomain.CurrentDomain.Load(typeof(NpsConfig).Assembly.GetName());
3941

40-
//seems like I need to pre-load my dependencies
41-
AppDomain.CurrentDomain.Load(typeof(NpsConfig).Assembly.GetName() );
42-
4342
ExecuteStartupScript();
4443
return;
4544
}
@@ -56,8 +55,8 @@ private static void ExecuteStartupScript()
5655
var startupScript = GetStartupScript();
5756
if (startupScript != null)
5857
{
59-
var executor = new ScriptExecutor(GetConfig() );
60-
var result = executor.ExecuteScript(startupScript, GetStartupScriptPath() );
58+
var executor = new ScriptExecutor(GetConfig());
59+
var result = executor.ExecuteScript(startupScript, GetStartupScriptPath());
6160
if (result == -1)
6261
{
6362
Forms.MessageBox.Show(executor.Message, "NavisPythonShell - StartupScript");
@@ -117,10 +116,10 @@ public static void OnUnloading()
117116
// FIXME: deallocate the python shell...
118117
return;
119118
}
120-
119+
121120
public static IRpsConfig GetConfig()
122-
{
123-
return new NpsConfig(GetSettingsFile() );
121+
{
122+
return new NpsConfig(GetSettingsFile());
124123
}
125124

126125
/// <summary>
@@ -145,12 +144,12 @@ private static string GetSettingsFile()
145144
/// </summary>
146145
private static string GetSettingsFolder()
147146
{
148-
if (!string.IsNullOrEmpty(settingsFolder) )
149-
{
150-
return settingsFolder;
151-
}
152-
//return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NavisPythonShell" + versionNumber);
153-
return Path.GetDirectoryName(typeof(NavisPythonShellApplication).Assembly.Location);
147+
if (!string.IsNullOrEmpty(settingsFolder))
148+
{
149+
return settingsFolder;
150+
}
151+
//return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NavisPythonShell" + versionNumber);
152+
return Path.GetDirectoryName(typeof(NavisPythonShellApplication).Assembly.Location);
154153
}
155154

156155
/// <summary>
@@ -166,7 +165,7 @@ public static IEnumerable<Command> GetCommands(XDocument repository)
166165
var commandName = commandNode.Attribute("name").Value;
167166
var commandSrc = commandNode.Attribute("src").Value;
168167
var group = commandNode.Attribute("group") == null ? "" : commandNode.Attribute("group").Value;
169-
168+
170169
ImageSource largeImage = null;
171170
if (IsValidPath(commandNode.Attribute("largeImage")))
172171
{
@@ -188,14 +187,15 @@ public static IEnumerable<Command> GetCommands(XDocument repository)
188187
{
189188
smallImage = GetEmbeddedPng(addinAssembly, "NavisPythonShell.Resources.PythonScript16x16.png");
190189
}
191-
192-
yield return new Command {
193-
Name = commandName,
194-
Source = commandSrc,
195-
Group = group,
196-
LargeImage = largeImage,
197-
SmallImage = smallImage,
198-
Index = i++
190+
191+
yield return new Command
192+
{
193+
Name = commandName,
194+
Source = commandSrc,
195+
Group = group,
196+
LargeImage = largeImage,
197+
SmallImage = smallImage,
198+
Index = i++
199199
};
200200
}
201201
}
@@ -334,7 +334,7 @@ public static string GetStartupScript()
334334
/// </summary>
335335
public static void WriteSettings(
336336
IEnumerable<Command> commands,
337-
IEnumerable<string> searchPaths,
337+
IEnumerable<string> searchPaths,
338338
IEnumerable<KeyValuePair<string, string>> variables,
339339
string initScript,
340340
string startupScript)
@@ -368,13 +368,13 @@ public static void WriteSettings(
368368
foreach (var command in commands)
369369
{
370370
xmlCommands.Add(new XElement(
371-
"Command",
372-
new XAttribute("name", command.Name),
371+
"Command",
372+
new XAttribute("name", command.Name),
373373
new XAttribute("src", command.Source),
374374
new XAttribute("group", command.Group)));
375375

376376
}
377-
doc.Root.Add(xmlCommands);
377+
doc.Root.Add(xmlCommands);
378378

379379
// add search paths
380380
var xmlSearchPaths = new XElement("SearchPaths");
@@ -423,7 +423,7 @@ internal class Command
423423
public string Source;
424424
public int Index;
425425
public ImageSource LargeImage;
426-
public ImageSource SmallImage;
426+
public ImageSource SmallImage;
427427

428428
public override string ToString()
429429
{

NpsRuntime/NpsRuntime.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@
6464
<Prefer32Bit />
6565
</PropertyGroup>
6666
<ItemGroup>
67-
<Reference Include="Autodesk.Navisworks.Api">
68-
<SpecificVersion>False</SpecificVersion>
69-
<HintPath>C:\Program Files\Autodesk\Navisworks Manage 2020\Autodesk.Navisworks.Api.dll</HintPath>
70-
<Private>False</Private>
67+
<Reference Include="Autodesk.Navisworks.Api, Version=19.0.1374.1, Culture=neutral, PublicKeyToken=d85e58fa5af9b484">
68+
<HintPath>C:\Program Files\Autodesk\Navisworks Manage 2022\Autodesk.Navisworks.Api.dll</HintPath>
7169
</Reference>
7270
<Reference Include="ICSharpCode.AvalonEdit, Version=5.0.3.0, Culture=neutral, PublicKeyToken=9cc39be672370310, processorArchitecture=MSIL">
7371
<SpecificVersion>False</SpecificVersion>

NpsRuntime/ScriptExecutor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ public void SetupEnvironment(ScriptEngine engine, ScriptScope scope)
141141
AddSearchPaths(engine);
142142
AddEmbeddedLib(engine);
143143

144-
// reference RevitAPI and RevitAPIUI
144+
// reference Navisworks Api Document and Application
145145
engine.Runtime.LoadAssembly(typeof(Autodesk.Navisworks.Api.Document).Assembly);
146-
146+
engine.Runtime.LoadAssembly(typeof(Autodesk.Navisworks.Api.Application).Assembly);
147147
// also, allow access to the RPS internals
148148
engine.Runtime.LoadAssembly(typeof(NavisPythonShell.NpsRuntime.ScriptExecutor).Assembly);
149149
}

exclude.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Autodesk.Navisworks.Api.dll
2+
Autodesk.Navisworks.Api.xml
3+
ICSharpCode.AvalonEdit.dll
4+
IronPython.dll
5+
IronPython.Modules.dll
6+
IronPython.SQLite.dll
7+
IronPython.Wpf.dll
8+
Microsoft.Dynamic.dll
9+
Microsoft.Scripting.dll
10+
Microsoft.Scripting.Metadata.dll
11+
NpsRuntime.dll
12+
NpsRuntime.pdb
13+
PythonConsoleControl.dll
14+
PythonConsoleControl.pdb
15+
System.Windows.Controls.WpfPropertyGrid.dll
16+
WPG.dll

noexclude.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
init.py
2+
NavisPythonShell.dll
3+
NavisPythonShell.pdb
4+
NavisPythonShell.xml
5+
startup.py

0 commit comments

Comments
 (0)