Skip to content

Commit ddbf536

Browse files
authored
Merge pull request dimven#15 from chuongmep/tryfix
Fix problem with installer new version
2 parents 6279d17 + 16713bb commit ddbf536

14 files changed

Lines changed: 109 additions & 53 deletions

Images/devenv_9FXen0L47z.png

83.5 KB
Loading

Images/devenv_E5MD6kiAQC.png

80.7 KB
Loading

NavisPythonShell/IronPythonConsoleCommand.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Diagnostics;
66
using Microsoft.Scripting;
77
using System.Threading;
8+
using System.Windows.Interop;
89
using System.Windows.Threading;
910
using NavisPythonShell.NpsRuntime;
1011
using Forms = System.Windows.Forms;
@@ -97,6 +98,9 @@ public override int Execute(params string[] parameters)
9798
}
9899
});
99100
});
101+
WindowInteropHelper helper = new WindowInteropHelper(gui);
102+
IntPtr hander = Application.Gui.MainWindow.Handle;
103+
helper.Owner = hander;
100104
gui.ShowDialog();
101105
return 0;
102106
}

NavisPythonShell/NavisPythonShell.csproj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<NoWin32Manifest>False</NoWin32Manifest>
4242
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
4343
<OutputPath>bin\$(Configuration)\</OutputPath>
44+
<LangVersion>latest</LangVersion>
4445
</PropertyGroup>
4546
<PropertyGroup>
4647
<!-- see: http://thebuildingcoder.typepad.com/blog/2013/06/processor-architecture-mismatch-warning.html -->
@@ -87,8 +88,8 @@
8788
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
8889
</PropertyGroup>
8990
<ItemGroup>
90-
<Reference Include="Autodesk.Navisworks.Api">
91-
<HintPath>C:\Program Files\Autodesk\Navisworks Manage 2020\Autodesk.Navisworks.Api.dll</HintPath>
91+
<Reference Include="Autodesk.Navisworks.Api, Version=19.0.1374.1, Culture=neutral, PublicKeyToken=d85e58fa5af9b484">
92+
<HintPath>C:\Program Files\Autodesk\Navisworks Manage 2022\Autodesk.Navisworks.Api.dll</HintPath>
9293
<Private>False</Private>
9394
</Reference>
9495
<Reference Include="ICSharpCode.AvalonEdit, Version=5.0.3.0, Culture=neutral, PublicKeyToken=9cc39be672370310, processorArchitecture=MSIL">
@@ -271,6 +272,14 @@
271272
</ItemGroup>
272273
<ItemGroup />
273274
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
275+
<PropertyGroup>
276+
<PreBuildEvent>
277+
</PreBuildEvent>
278+
</PropertyGroup>
279+
<PropertyGroup>
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>
282+
</PropertyGroup>
274283
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
275284
Other similar extension points exist, see Microsoft.Common.targets.
276285
<Target Name="BeforeBuild">

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
{

NavisPythonShell/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

NavisPythonShell/init.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# these commands get executed in the current scope
22
# of each new shell (but not for canned commands)
33
from Autodesk.Navisworks.Api import *
4-
5-
doc = Application.ActiveDocument
4+
from Autodesk.Navisworks.Api.Clash import *
5+
app = Application
6+
doc = app.ActiveDocument
67
selection = doc.CurrentSelection.SelectedItems
7-
8+
docclash = DocumentExtensions.GetClash(doc)
89
def quit():
910
__window__.Close()
1011
exit = quit

NpsRuntime/NpsRuntime.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<WarningLevel>4</WarningLevel>
2222
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
2323
<OutputPath>bin\$(Configuration)\</OutputPath>
24+
<LangVersion>latest</LangVersion>
2425
</PropertyGroup>
2526
<PropertyGroup>
2627
<!-- see: http://thebuildingcoder.typepad.com/blog/2013/06/processor-architecture-mismatch-warning.html -->
@@ -64,10 +65,11 @@
6465
<Prefer32Bit />
6566
</PropertyGroup>
6667
<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>
68+
<Reference Include="Autodesk.Navisworks.Api, Version=19.0.1374.1, Culture=neutral, PublicKeyToken=d85e58fa5af9b484">
69+
<HintPath>C:\Program Files\Autodesk\Navisworks Manage 2022\Autodesk.Navisworks.Api.dll</HintPath>
70+
</Reference>
71+
<Reference Include="Autodesk.Navisworks.Clash, Version=19.0.1374.1, Culture=neutral, PublicKeyToken=d85e58fa5af9b484">
72+
<HintPath>C:\Program Files\Autodesk\Navisworks Manage 2022\Autodesk.Navisworks.Clash.dll</HintPath>
7173
</Reference>
7274
<Reference Include="ICSharpCode.AvalonEdit, Version=5.0.3.0, Culture=neutral, PublicKeyToken=9cc39be672370310, processorArchitecture=MSIL">
7375
<SpecificVersion>False</SpecificVersion>

NpsRuntime/ScriptExecutor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Microsoft.Scripting.Hosting;
77
using System.Collections.Generic;
88
using Autodesk.Navisworks.Api;
9-
9+
using Autodesk.Navisworks.Api.Clash;
1010
namespace NavisPythonShell.NpsRuntime
1111
{
1212
/// <summary>
@@ -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.Clash.ClashTest).Assembly);
147147
// also, allow access to the RPS internals
148148
engine.Runtime.LoadAssembly(typeof(NavisPythonShell.NpsRuntime.ScriptExecutor).Assembly);
149149
}

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,28 @@ The biggest limitation is that you can't deploy DLLs with custom scripts at this
2424

2525
- Reference the version of "Autodesk.Navisworks.Api.dll" that you'd like to target.
2626
- Compile the solution.
27-
- Go to the "%APPDATA%\Autodesk Navisworks Manage 2020\" (or the version that you'd like to target)
27+
- Go to the "C:\Program Files\Autodesk\Navisworks Manage {version}\Plugins" (with version a version current of navisworks)
2828
- If there is no "Plugins" foler, create it
29-
- In the "Plugins" folder create a "NavisPythonShell" folder
30-
- Copy the contents of the build folder (usually ".\NavisPythonShell\NavisPythonShell\bin\$(Configuration)\" ) to the "\Plugins\NavisPythonShell\" folder
31-
- The final plugin directory should be similar to "%APPDATA%\Autodesk Navisworks Manage 2020\Plugins\NavisPythonShell"
29+
- Change Permisstions of two folder `Plugins` and `Dependencies` in properties
30+
31+
![](Images/devenv_9FXen0L47z.png)
32+
33+
![](Images/devenv_E5MD6kiAQC.png)
34+
35+
- Build Solution(if you change `version` of navisworks, please change number version in post build event)
36+
```
37+
xcopy $(TargetDir)*.* "C:\Program Files\Autodesk\Navisworks Manage {version}\Plugins\NavisPythonShell\" /Y /I /E /EXCLUDE:$(SolutionDir)exclude.txt
38+
39+
xcopy $(TargetDir)*.* "C:\Program Files\Autodesk\Navisworks Manage {version}\Dependencies\" /Y /I /E /EXCLUDE:$(SolutionDir)noexclude.txt
40+
41+
```
3242
3343
OR
3444
35-
- Download a valid [release zip](https://github.com/dimven/NavisPythonShell/releases) for your version of Navisworks.
36-
- Extract the zip to "%APPDATA%\Autodesk Navisworks Manage 2020\Plugins" (or whichever version of Navisworks you're targeting)
45+
- Download a valid [release zip](https://github.com/dimven/NavisPythonShell/releases) for your `version` of Navisworks.
46+
- Extract the zip to two folder:
47+
- "C:\Program Files\Autodesk\Autodesk Navisworks Manage {version}\Plugins" : include all file in noexclude.txt and folder icon
48+
- "C:\Program Files\Autodesk\Autodesk Navisworks Manage {version}\Dependencies" : include all file in exclude.txt
3749
3850
## Contribute
3951

0 commit comments

Comments
 (0)