diff --git a/Images/devenv_9FXen0L47z.png b/Images/devenv_9FXen0L47z.png new file mode 100644 index 0000000..502c6c0 Binary files /dev/null and b/Images/devenv_9FXen0L47z.png differ diff --git a/Images/devenv_E5MD6kiAQC.png b/Images/devenv_E5MD6kiAQC.png new file mode 100644 index 0000000..a430312 Binary files /dev/null and b/Images/devenv_E5MD6kiAQC.png differ diff --git a/NavisPythonShell/IronPythonConsoleCommand.cs b/NavisPythonShell/IronPythonConsoleCommand.cs index bc9b8ab..c0acdc1 100644 --- a/NavisPythonShell/IronPythonConsoleCommand.cs +++ b/NavisPythonShell/IronPythonConsoleCommand.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using Microsoft.Scripting; using System.Threading; +using System.Windows.Interop; using System.Windows.Threading; using NavisPythonShell.NpsRuntime; using Forms = System.Windows.Forms; @@ -97,6 +98,9 @@ public override int Execute(params string[] parameters) } }); }); + WindowInteropHelper helper = new WindowInteropHelper(gui); + IntPtr hander = Application.Gui.MainWindow.Handle; + helper.Owner = hander; gui.ShowDialog(); return 0; } diff --git a/NavisPythonShell/NavisPythonShell.csproj b/NavisPythonShell/NavisPythonShell.csproj index c5a6291..64cc374 100644 --- a/NavisPythonShell/NavisPythonShell.csproj +++ b/NavisPythonShell/NavisPythonShell.csproj @@ -41,6 +41,7 @@ False OnBuildSuccess bin\$(Configuration)\ + latest @@ -49,7 +50,7 @@ - v4.7 + v4.8 DEBUG;TRACE Full @@ -87,40 +88,40 @@ obj\ - - C:\Program Files\Autodesk\Navisworks Manage 2020\Autodesk.Navisworks.Api.dll - False + + False + ..\RefrencedAssemblies\Sim2025\Autodesk.Navisworks.Api.dll - + False ..\RefrencedAssemblies\ICSharpCode.AvalonEdit.dll - + False ..\RefrencedAssemblies\IronPython.dll - + False ..\RefrencedAssemblies\IronPython.Modules.dll - + False ..\RefrencedAssemblies\IronPython.SQLite.dll - + False ..\RefrencedAssemblies\IronPython.Wpf.dll - + False ..\RefrencedAssemblies\Microsoft.Dynamic.dll - + False ..\RefrencedAssemblies\Microsoft.Scripting.dll - + False ..\RefrencedAssemblies\Microsoft.Scripting.Metadata.dll @@ -131,7 +132,7 @@ 3.5 - + False ..\RefrencedAssemblies\System.Windows.Controls.WpfPropertyGrid.dll @@ -271,6 +272,15 @@ + + + + + + xcopy $(TargetDir)*.* "C:\Program Files\Autodesk\Navisworks Simulate 2025\Plugins\NavisPythonShell\" /Y /I /E /EXCLUDE:$(SolutionDir)exclude.txt +xcopy $(TargetDir)*.* "C:\Program Files\Autodesk\Navisworks Simulate 2025\Dependencies\" /Y /I /E /EXCLUDE:$(SolutionDir)noexclude.txt + + @@ -29,7 +30,7 @@ - v4.7 + v4.8 DEBUG;TRACE False Full @@ -64,10 +65,17 @@ - + + False + ..\RefrencedAssemblies\Sim2025\Autodesk.Navisworks.Api.dll + + + False + ..\RefrencedAssemblies\Sim2025\Autodesk.Navisworks.Clash.dll + + False - C:\Program Files\Autodesk\Navisworks Manage 2020\Autodesk.Navisworks.Api.dll - False + ..\RefrencedAssemblies\Sim2025\Autodesk.Navisworks.Timeliner.dll False diff --git a/NpsRuntime/ScriptExecutor.cs b/NpsRuntime/ScriptExecutor.cs index 7baac75..d26d305 100644 --- a/NpsRuntime/ScriptExecutor.cs +++ b/NpsRuntime/ScriptExecutor.cs @@ -6,7 +6,8 @@ using Microsoft.Scripting.Hosting; using System.Collections.Generic; using Autodesk.Navisworks.Api; - +using Autodesk.Navisworks.Api.Clash; +using Autodesk.Navisworks.Api.Timeliner; namespace NavisPythonShell.NpsRuntime { /// @@ -141,9 +142,10 @@ public void SetupEnvironment(ScriptEngine engine, ScriptScope scope) AddSearchPaths(engine); AddEmbeddedLib(engine); - // reference RevitAPI and RevitAPIUI + // reference Navisworks Api Document and Application engine.Runtime.LoadAssembly(typeof(Autodesk.Navisworks.Api.Document).Assembly); - + engine.Runtime.LoadAssembly(typeof(Autodesk.Navisworks.Api.Clash.ClashTest).Assembly); + engine.Runtime.LoadAssembly(typeof(Autodesk.Navisworks.Api.Timeliner.DocumentTimeliner).Assembly); // also, allow access to the RPS internals engine.Runtime.LoadAssembly(typeof(NavisPythonShell.NpsRuntime.ScriptExecutor).Assembly); } diff --git a/PythonConsoleControl/PythonConsoleControl.csproj b/PythonConsoleControl/PythonConsoleControl.csproj index 761d2f1..0ddfd4c 100644 --- a/PythonConsoleControl/PythonConsoleControl.csproj +++ b/PythonConsoleControl/PythonConsoleControl.csproj @@ -42,7 +42,7 @@ bin\$(Configuration)\ - v4.7 + v4.8 Full DEBUG;TRACE False diff --git a/README.md b/README.md index 55b4b8c..cd41bb6 100644 --- a/README.md +++ b/README.md @@ -24,16 +24,28 @@ The biggest limitation is that you can't deploy DLLs with custom scripts at this - Reference the version of "Autodesk.Navisworks.Api.dll" that you'd like to target. - Compile the solution. -- Go to the "%APPDATA%\Autodesk Navisworks Manage 2020\" (or the version that you'd like to target) +- Go to the "C:\Program Files\Autodesk\Navisworks Manage {version}\Plugins" (with version being the current version of your navisworks) - If there is no "Plugins" foler, create it - - In the "Plugins" folder create a "NavisPythonShell" folder - - Copy the contents of the build folder (usually ".\NavisPythonShell\NavisPythonShell\bin\$(Configuration)\" ) to the "\Plugins\NavisPythonShell\" folder - - The final plugin directory should be similar to "%APPDATA%\Autodesk Navisworks Manage 2020\Plugins\NavisPythonShell" + - Change Permisstions of two folder `Plugins` and `Dependencies` in properties + + ![](Images/devenv_9FXen0L47z.png) + + ![](Images/devenv_E5MD6kiAQC.png) + + - Build Solution(if you change `version` of navisworks, please change number version in post build event) + ``` + xcopy $(TargetDir)*.* "C:\Program Files\Autodesk\Navisworks Manage {version}\Plugins\NavisPythonShell\" /Y /I /E /EXCLUDE:$(SolutionDir)exclude.txt + + xcopy $(TargetDir)*.* "C:\Program Files\Autodesk\Navisworks Manage {version}\Dependencies\" /Y /I /E /EXCLUDE:$(SolutionDir)noexclude.txt + + ``` OR -- Download a valid [release zip](https://github.com/dimven/NavisPythonShell/releases) for your version of Navisworks. -- Extract the zip to "%APPDATA%\Autodesk Navisworks Manage 2020\Plugins" (or whichever version of Navisworks you're targeting) +- Download a valid [release zip](https://github.com/dimven/NavisPythonShell/releases) for your `version` of Navisworks. +- Extract the zip to two folder: + - "C:\Program Files\Autodesk\Autodesk Navisworks Manage {version}\Plugins" : include all file in noexclude.txt and folder icon + - "C:\Program Files\Autodesk\Autodesk Navisworks Manage {version}\Dependencies" : include all file in exclude.txt ## Contribute diff --git a/RefrencedAssemblies/Microsoft.CSharp.dll b/RefrencedAssemblies/Microsoft.CSharp.dll new file mode 100644 index 0000000..f11e2a9 Binary files /dev/null and b/RefrencedAssemblies/Microsoft.CSharp.dll differ diff --git a/RefrencedAssemblies/Microsoft.Scripting.AspNet.dll b/RefrencedAssemblies/Microsoft.Scripting.AspNet.dll new file mode 100644 index 0000000..ecbec45 Binary files /dev/null and b/RefrencedAssemblies/Microsoft.Scripting.AspNet.dll differ diff --git a/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Api.dll b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Api.dll new file mode 100644 index 0000000..20a13a8 Binary files /dev/null and b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Api.dll differ diff --git a/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Automation.dll b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Automation.dll new file mode 100644 index 0000000..8860501 Binary files /dev/null and b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Automation.dll differ diff --git a/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Clash.dll b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Clash.dll new file mode 100644 index 0000000..f6419bd Binary files /dev/null and b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Clash.dll differ diff --git a/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.ComApi.dll b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.ComApi.dll new file mode 100644 index 0000000..21ec27f Binary files /dev/null and b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.ComApi.dll differ diff --git a/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Controls.dll b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Controls.dll new file mode 100644 index 0000000..f9239b7 Binary files /dev/null and b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Controls.dll differ diff --git a/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Interop.ComApi.dll b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Interop.ComApi.dll new file mode 100644 index 0000000..79eb867 Binary files /dev/null and b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Interop.ComApi.dll differ diff --git a/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Timeliner.dll b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Timeliner.dll new file mode 100644 index 0000000..36d79e4 Binary files /dev/null and b/RefrencedAssemblies/Sim2023/Autodesk.Navisworks.Timeliner.dll differ diff --git a/RefrencedAssemblies/Sim2023/lcclash.dll b/RefrencedAssemblies/Sim2023/lcclash.dll new file mode 100644 index 0000000..ae17578 Binary files /dev/null and b/RefrencedAssemblies/Sim2023/lcclash.dll differ diff --git a/RefrencedAssemblies/Sim2024/Autodesk.Navisworks.Api.dll b/RefrencedAssemblies/Sim2024/Autodesk.Navisworks.Api.dll new file mode 100644 index 0000000..27a9ba6 Binary files /dev/null and b/RefrencedAssemblies/Sim2024/Autodesk.Navisworks.Api.dll differ diff --git a/RefrencedAssemblies/Sim2024/Autodesk.Navisworks.Automation.dll b/RefrencedAssemblies/Sim2024/Autodesk.Navisworks.Automation.dll new file mode 100644 index 0000000..cae5cf5 Binary files /dev/null and b/RefrencedAssemblies/Sim2024/Autodesk.Navisworks.Automation.dll differ diff --git a/RefrencedAssemblies/Sim2024/Autodesk.Navisworks.Clash.dll b/RefrencedAssemblies/Sim2024/Autodesk.Navisworks.Clash.dll new file mode 100644 index 0000000..b9a3226 Binary files /dev/null and b/RefrencedAssemblies/Sim2024/Autodesk.Navisworks.Clash.dll differ diff --git a/RefrencedAssemblies/Sim2024/lcclash.dll b/RefrencedAssemblies/Sim2024/lcclash.dll new file mode 100644 index 0000000..919493b Binary files /dev/null and b/RefrencedAssemblies/Sim2024/lcclash.dll differ diff --git a/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Api.dll b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Api.dll new file mode 100644 index 0000000..c12ac6e Binary files /dev/null and b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Api.dll differ diff --git a/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Automation.dll b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Automation.dll new file mode 100644 index 0000000..68df521 Binary files /dev/null and b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Automation.dll differ diff --git a/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Clash.dll b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Clash.dll new file mode 100644 index 0000000..88095ff Binary files /dev/null and b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Clash.dll differ diff --git a/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.ComApi.dll b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.ComApi.dll new file mode 100644 index 0000000..7d39fbb Binary files /dev/null and b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.ComApi.dll differ diff --git a/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Controls.dll b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Controls.dll new file mode 100644 index 0000000..6ba367a Binary files /dev/null and b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Controls.dll differ diff --git a/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Interop.ComApi.dll b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Interop.ComApi.dll new file mode 100644 index 0000000..79df263 Binary files /dev/null and b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Interop.ComApi.dll differ diff --git a/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Timeliner.dll b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Timeliner.dll new file mode 100644 index 0000000..4ef338f Binary files /dev/null and b/RefrencedAssemblies/Sim2025/Autodesk.Navisworks.Timeliner.dll differ diff --git a/RefrencedAssemblies/Sim2025/lcclash.dll b/RefrencedAssemblies/Sim2025/lcclash.dll new file mode 100644 index 0000000..de95d7e Binary files /dev/null and b/RefrencedAssemblies/Sim2025/lcclash.dll differ diff --git a/RequiredLibraries/old/ICSharpCode.AvalonEdit.dll b/RequiredLibraries/old/ICSharpCode.AvalonEdit.dll new file mode 100644 index 0000000..69ed201 Binary files /dev/null and b/RequiredLibraries/old/ICSharpCode.AvalonEdit.dll differ diff --git a/RequiredLibraries/old/IronPython.Modules.dll b/RequiredLibraries/old/IronPython.Modules.dll new file mode 100644 index 0000000..f9ae5c2 Binary files /dev/null and b/RequiredLibraries/old/IronPython.Modules.dll differ diff --git a/RequiredLibraries/old/IronPython.SQLite.dll b/RequiredLibraries/old/IronPython.SQLite.dll new file mode 100644 index 0000000..3b46157 Binary files /dev/null and b/RequiredLibraries/old/IronPython.SQLite.dll differ diff --git a/RequiredLibraries/old/IronPython.Wpf.dll b/RequiredLibraries/old/IronPython.Wpf.dll new file mode 100644 index 0000000..8399ec3 Binary files /dev/null and b/RequiredLibraries/old/IronPython.Wpf.dll differ diff --git a/RequiredLibraries/old/IronPython.dll b/RequiredLibraries/old/IronPython.dll new file mode 100644 index 0000000..3a7e463 Binary files /dev/null and b/RequiredLibraries/old/IronPython.dll differ diff --git a/RequiredLibraries/old/Microsoft.CSharp.dll b/RequiredLibraries/old/Microsoft.CSharp.dll new file mode 100644 index 0000000..f11e2a9 Binary files /dev/null and b/RequiredLibraries/old/Microsoft.CSharp.dll differ diff --git a/RequiredLibraries/old/Microsoft.Dynamic.dll b/RequiredLibraries/old/Microsoft.Dynamic.dll new file mode 100644 index 0000000..0d7e6a7 Binary files /dev/null and b/RequiredLibraries/old/Microsoft.Dynamic.dll differ diff --git a/RequiredLibraries/old/Microsoft.Scripting.AspNet.dll b/RequiredLibraries/old/Microsoft.Scripting.AspNet.dll new file mode 100644 index 0000000..ecbec45 Binary files /dev/null and b/RequiredLibraries/old/Microsoft.Scripting.AspNet.dll differ diff --git a/RequiredLibraries/old/Microsoft.Scripting.Metadata.dll b/RequiredLibraries/old/Microsoft.Scripting.Metadata.dll new file mode 100644 index 0000000..c3cda22 Binary files /dev/null and b/RequiredLibraries/old/Microsoft.Scripting.Metadata.dll differ diff --git a/RequiredLibraries/old/Microsoft.Scripting.dll b/RequiredLibraries/old/Microsoft.Scripting.dll new file mode 100644 index 0000000..3f0771a Binary files /dev/null and b/RequiredLibraries/old/Microsoft.Scripting.dll differ diff --git a/RequiredLibraries/old/System.Windows.Controls.WpfPropertyGrid.dll b/RequiredLibraries/old/System.Windows.Controls.WpfPropertyGrid.dll new file mode 100644 index 0000000..8d9f2d1 Binary files /dev/null and b/RequiredLibraries/old/System.Windows.Controls.WpfPropertyGrid.dll differ diff --git a/RequiredLibraries/old/WPG.dll b/RequiredLibraries/old/WPG.dll new file mode 100644 index 0000000..ea4623a Binary files /dev/null and b/RequiredLibraries/old/WPG.dll differ diff --git a/Script Examples/ClashTest.nwd b/Script Examples/ClashTest.nwd new file mode 100644 index 0000000..b1af06d Binary files /dev/null and b/Script Examples/ClashTest.nwd differ diff --git a/Script Examples/CreateSearchSets_Timeliner.py b/Script Examples/CreateSearchSets_Timeliner.py new file mode 100644 index 0000000..a4cb0cd --- /dev/null +++ b/Script Examples/CreateSearchSets_Timeliner.py @@ -0,0 +1,54 @@ +import datetime +# build period names from start to end +# set the periods from the beginning of the job to the end of the job +SearchFolderName = 'OPD_TimeLiner' +yr_beg = 2023 +wk_beg = 51 +yr_end = 2025 +wk_end = 9 +listof = [] +for y in range(yr_beg, yr_end + 1): + if yr_beg == yr_end: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(wk_beg, wk_end + 1)] + elif y == yr_end: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(1, wk_end + 1)] + elif y == yr_beg: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(wk_beg, 53 + 1)] + else: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(1, 53 + 1)] + listof.append(wlist) + +#confirm SearchFolderName doesn't already exist, rename _old +for ss in doc.SelectionSets.RootItem.Children: + if ss.DisplayName == SearchFolderName and ss.IsGroup: + doc.SelectionSets.EditDisplayName(ss, SearchFolderName + "_old") + # perhaps the old one should just be deleted + +#create new "timeliner" folder at the end of the existing search sets +nextIndex = doc.SelectionSets.RootItem.Children.Count +savedFolder = FolderItem() +savedFolder.DisplayName = SearchFolderName + +for y in listof: + yr = y[0] + yearFolder = FolderItem() + yearFolder.DisplayName = str(yr) + for wk in y[1:]: + # create another folder group for each year + s = Search() + # sc = SearchCondition.HasPropertyByDisplayName('OPD_LineList','SCHEDULED INSTALL') + # ABOVE IS CORRECT, BELOW IS FOR TESTING AND PROOF OF CONCEPT + sc = SearchCondition.HasPropertyByDisplayName('OPD_Schedule','SCHEDULED INSTALL') + oData = VariantData.FromDisplayString(wk) + sc = sc.EqualValue(oData) + s.SearchConditions.Add(sc) + s.Selection.SelectAll() + s.Locations = SearchLocations.DescendantsAndSelf + savedSet = SelectionSet(s) + savedSet.DisplayName = wk + yearFolder.Children.Add(savedSet) + savedFolder.Children.Add(yearFolder) + +doc.SelectionSets.InsertCopy(nextIndex, savedFolder) + + diff --git a/Script Examples/CreateTimeLiner_Timeliner.py b/Script Examples/CreateTimeLiner_Timeliner.py new file mode 100644 index 0000000..478fc80 --- /dev/null +++ b/Script Examples/CreateTimeLiner_Timeliner.py @@ -0,0 +1,33 @@ +from datetime import datetime +from datetime import timedelta + +# build period names from start to end +# set the periods from the beginning of the job to the end of the job +yr_beg = 2023 +wk_beg = 51 +yr_end = 2025 +wk_end = 9 +listof = [] +for y in range(yr_beg, yr_end + 1): + if yr_beg == yr_end: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(wk_beg, wk_end + 1)] + elif y == yr_end: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(1, wk_end + 1)] + elif y == yr_beg: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(wk_beg, 53 + 1)] + else: + wlist = [str(y)] + [str(y) + '.' + element.__str__() for element in range(1, 53 + 1)] + listof.append(wlist) + + +#create time timeler entries to match up with search sets and link +#need to identify week beginning and ending dates for planned start/end +# dtStart = datetime.datetime.strptime("") +for y in listof: + yr = y[0] + for wk in y[1:]: + d = wk + # d = "2024.1" + dtStart = datetime.strptime(d + '-1', "%Y.%W-%w") + timedelta(days=-1) + dtEnd = dtStart + timedelta(days=6) + print(dtEnd) \ No newline at end of file diff --git a/Script Examples/CreateViewPoint_per_Area.py b/Script Examples/CreateViewPoint_per_Area.py new file mode 100644 index 0000000..3bf4188 --- /dev/null +++ b/Script Examples/CreateViewPoint_per_Area.py @@ -0,0 +1,43 @@ +# Search +# first build a collection of objects that have an area. +# in order to get a list of all the areas available +# search doesn't work for custom categories, must iterate +areas = dict() +allItems = doc.Models.RootItemDescendantsAndSelf +for item in allItems: + prop = item.PropertyCategories.FindPropertyByDisplayName('OPD_LineList','Area') + if prop: + areaName = prop.Value.ToDisplayString() + if areaName not in areas.keys(): + mic = ModelItemCollection() + mic.Add(item) + areas[areaName] = mic + else: + mic = areas[areaName] + mic.Add(item) + areas[areaName] = mic + +for area, mic in areas.items(): + # remove existing viewpoint if exists + vps = doc.SavedViewpoints.RootItem.Children + for svp in vps: + vpName = svp.DisplayName.ToString() + if (vpName == area): + doc.SavedViewpoints.Remove(svp) + # set all of model transparency + # might be worth seeing if the viewpoint can just be edited for items visibility instead of editing the model + doc.Models.OverrideTemporaryTransparency(doc.Models.RootItemDescendants,50) + # set for current area to no transparency + doc.Models.OverrideTemporaryTransparency(mic,0) + bbc = mic.BoundingBox().Center + nvp = Viewpoint() + nvp.Position = bbc + vt = Vector3D(0,1,0) + nvp.AlignDirection(vt) + nvp.RenderStyle.Shaded + nvp.HeightField = 0.872657 + svp = SavedViewpoint(nvp) + svp.DisplayName = area + print svp.DisplayName + doc.SavedViewpoints.AddCopy(svp) + diff --git a/Script Examples/CreateViewPoint_per_NWC.py b/Script Examples/CreateViewPoint_per_NWC.py new file mode 100644 index 0000000..b862078 --- /dev/null +++ b/Script Examples/CreateViewPoint_per_NWC.py @@ -0,0 +1,39 @@ +# Search +s = Search() +s.Selection.SelectAll() +# variant needed for equals Value +# oData = VariantData.FromDisplayString('Rooms') +sc1 = SearchCondition.HasPropertyByDisplayName("Item","Name") +# oSearchCondition = oSearchCondition.EqualValue(oData) +sc1 = sc1.DisplayStringContains('.nwc') +s.SearchConditions.Add(sc1) +a = s.FindAll(doc,False) + +# Create Collection and fill it with the items found +modelItems = ModelItemCollection() +a.CopyTo(modelItems) + +# Loop through collection of found items +for item in modelItems: + # Get some properties to build the view name later + # This would change for OPD use case + #number = item.PropertyCategories.FindPropertyByDisplayName('Element', 'Number') + #strnumb = number.Value.ToDisplayString() + name = item.PropertyCategories.FindPropertyByDisplayName ('Item', 'Name') + strname = name.Value.ToDisplayString() + # This next pert is locating the camera, so if we're focusing on an item, + # then OPD will again need to tweak this section to put the camera + # in the correct location and orientation + bbc = item.BoundingBox().Center + nvp = Viewpoint() + nvp.Position = bbc + vt = Vector3D(0,1,0) + nvp.AlignDirection(vt) + nvp.RenderStyle.Shaded + nvp.HeightField = 0.872657 + # Save the settings to a view + svp = SavedViewpoint(nvp) + #svp.DisplayName = strnumb + " " + strname + svp.DisplayName = strname + print svp.DisplayName + doc.SavedViewpoints.AddCopy(svp) \ No newline at end of file diff --git a/Script Examples/GetClashTest.py b/Script Examples/GetClashTest.py new file mode 100644 index 0000000..9677eab --- /dev/null +++ b/Script Examples/GetClashTest.py @@ -0,0 +1,7 @@ +testdata = docclash.TestsData +tests = testdata.Tests +for test in tests: + SavedItemCollection = test.Children + for saveitem in SavedItemCollection: + print(saveitem.DisplayName) + print(saveitem.Center) \ No newline at end of file diff --git a/Script Examples/PrintBaseFiles(from NWD).py b/Script Examples/PrintBaseFiles(from NWD).py new file mode 100644 index 0000000..81e948f --- /dev/null +++ b/Script Examples/PrintBaseFiles(from NWD).py @@ -0,0 +1,2 @@ +for model in doc.Models.First.RootItem.Children: + print(model.DisplayName) \ No newline at end of file diff --git a/Script Examples/PrintBaseFiles(from NWF).py b/Script Examples/PrintBaseFiles(from NWF).py new file mode 100644 index 0000000..88d11e0 --- /dev/null +++ b/Script Examples/PrintBaseFiles(from NWF).py @@ -0,0 +1,2 @@ +for model in doc.Models: + print(model.FileName) \ No newline at end of file diff --git a/Script Examples/PrintBaseSourceFileName(from NWD).py b/Script Examples/PrintBaseSourceFileName(from NWD).py new file mode 100644 index 0000000..d0ed8c1 --- /dev/null +++ b/Script Examples/PrintBaseSourceFileName(from NWD).py @@ -0,0 +1,5 @@ +for model in doc.Models.First.RootItem.Children: + prop = model.PropertyCategories.FindPropertyByDisplayName("Item","Source File Name") + sourcefile_long = prop.Value.ToString() + sourceFileName = sourcefile_long.Replace("DisplayString:", "") + print(sourceFileName) \ No newline at end of file diff --git a/Script Examples/totalItems.py b/Script Examples/totalItems.py new file mode 100644 index 0000000..5a5623c --- /dev/null +++ b/Script Examples/totalItems.py @@ -0,0 +1,15 @@ +root = doc.Models[0].RootItem + +total = 0 + +def getTotal(x): + if x.DisplayName == "Body": + return 1 + return sum(map(getTotal, x.Children)) + +for c in root.Children: + t = getTotal(c) + total += t + print c.DisplayName, " | ", t + +print "Total items: ", total diff --git a/exclude.txt b/exclude.txt new file mode 100644 index 0000000..0424ded --- /dev/null +++ b/exclude.txt @@ -0,0 +1,16 @@ +Autodesk.Navisworks.Api.dll +Autodesk.Navisworks.Api.xml +ICSharpCode.AvalonEdit.dll +IronPython.dll +IronPython.Modules.dll +IronPython.SQLite.dll +IronPython.Wpf.dll +Microsoft.Dynamic.dll +Microsoft.Scripting.dll +Microsoft.Scripting.Metadata.dll +NpsRuntime.dll +NpsRuntime.pdb +PythonConsoleControl.dll +PythonConsoleControl.pdb +System.Windows.Controls.WpfPropertyGrid.dll +WPG.dll \ No newline at end of file diff --git a/noexclude.txt b/noexclude.txt new file mode 100644 index 0000000..d08b42c --- /dev/null +++ b/noexclude.txt @@ -0,0 +1,5 @@ +init.py +NavisPythonShell.dll +NavisPythonShell.pdb +NavisPythonShell.xml +startup.py \ No newline at end of file