diff --git a/Grasshopper_Engine/Grasshopper_Engine.csproj b/Grasshopper_Engine/Grasshopper_Engine.csproj index 93f2c704..b1043319 100644 --- a/Grasshopper_Engine/Grasshopper_Engine.csproj +++ b/Grasshopper_Engine/Grasshopper_Engine.csproj @@ -1,4 +1,4 @@ - + @@ -35,26 +35,26 @@ False - C:\ProgramData\BHoM\Assemblies\BHoM.dll + $(ProgramData)\BHoM\Assemblies\BHoM.dll False False - C:\ProgramData\BHoM\Assemblies\BHoM_Engine.dll + $(ProgramData)\BHoM\Assemblies\BHoM_Engine.dll False - C:\ProgramData\BHoM\Assemblies\BHoM_UI.dll + $(ProgramData)\BHoM\Assemblies\BHoM_UI.dll False False - C:\ProgramData\BHoM\Assemblies\Data_Engine.dll + $(ProgramData)\BHoM\Assemblies\Data_Engine.dll False False - C:\ProgramData\BHoM\Assemblies\Dimensional_oM.dll + $(ProgramData)\BHoM\Assemblies\Dimensional_oM.dll False False @@ -63,11 +63,11 @@ False - C:\ProgramData\BHoM\Assemblies\Geometry_Engine.dll + $(ProgramData)\BHoM\Assemblies\Geometry_Engine.dll False - C:\ProgramData\BHoM\Assemblies\Geometry_oM.dll + $(ProgramData)\BHoM\Assemblies\Geometry_oM.dll False False @@ -75,7 +75,7 @@ ..\packages\Grasshopper.6.33.20343.16431\lib\net45\GH_IO.dll - C:\ProgramData\BHoM\Assemblies\Graphics_oM.dll + $(ProgramData)\BHoM\Assemblies\Graphics_oM.dll False False @@ -83,13 +83,13 @@ ..\packages\Grasshopper.6.33.20343.16431\lib\net45\Grasshopper.dll - C:\ProgramData\BHoM\Assemblies\Programming_oM.dll + $(ProgramData)\BHoM\Assemblies\Programming_oM.dll False False False - C:\ProgramData\BHoM\Assemblies\Reflection_Engine.dll + $(ProgramData)\BHoM\Assemblies\Reflection_Engine.dll False @@ -97,7 +97,7 @@ False - C:\ProgramData\BHoM\Assemblies\Rhinoceros_Engine.dll + $(ProgramData)\BHoM\Assemblies\Rhinoceros_Engine.dll False @@ -105,7 +105,7 @@ False - C:\ProgramData\BHoM\Assemblies\Serialiser_Engine.dll + $(ProgramData)\BHoM\Assemblies\Serialiser_Engine.dll False @@ -118,12 +118,12 @@ - C:\ProgramData\BHoM\Assemblies\UI_Engine.dll + $(ProgramData)\BHoM\Assemblies\UI_Engine.dll False False - C:\ProgramData\BHoM\Assemblies\UI_oM.dll + $(ProgramData)\BHoM\Assemblies\UI_oM.dll False False @@ -137,6 +137,7 @@ + @@ -174,4 +175,4 @@ Copy /Y "$(TargetDir)$(TargetName).dll" "C:\ProgramData\BHoM\Assemblies\$(Target --> - \ No newline at end of file + diff --git a/Grasshopper_Engine/Query/CanvasFilePath.cs b/Grasshopper_Engine/Query/CanvasFilePath.cs new file mode 100644 index 00000000..78411f92 --- /dev/null +++ b/Grasshopper_Engine/Query/CanvasFilePath.cs @@ -0,0 +1,50 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using GH = Grasshopper; +using Grasshopper.Kernel; +using System.ComponentModel; +using BH.oM.Base.Attributes; + +namespace BH.Engine.Grasshopper +{ + public static partial class Query + { + [Description("Gets the saved file path of the currently open Grasshopper Document for the active canvas.")] + [Output("filePath", "The local file path for the active canvas.")] + public static string CanvasFilePath() + { + var ghDoc = GH.Instances.ActiveCanvas.Document; + if (ghDoc != null && ghDoc.IsFilePathDefined) + return ghDoc.FilePath; + + BH.Engine.Base.Compute.RecordWarning("Document has not been saved and does not yet have a file path defined."); + return ""; + } + } +}