diff --git a/Tuna.Revit.Build.props b/Tuna.Revit.Build.props new file mode 100644 index 0000000..c3c1f19 --- /dev/null +++ b/Tuna.Revit.Build.props @@ -0,0 +1,90 @@ + + + + Debug;Release; + Rvt_16_Debug;Rvt_16_Release; + Rvt_17_Debug;Rvt_17_Release; + Rvt_18_Debug;Rvt_18_Release; + Rvt_19_Debug;Rvt_19_Release; + Rvt_20_Debug;Rvt_20_Release; + Rvt_21_Debug;Rvt_21_Release; + Rvt_22_Debug;Rvt_22_Release; + Rvt_23_Debug;Rvt_23_Release; + Rvt_24_Debug;Rvt_24_Release; + Rvt_25_Debug;Rvt_25_Release; + + 15 + x64 + preview + + + + 2016 + Rvt_16 + net452 + 2016.2.$(TunaVer) + + + + 2017 + Rvt_17 + net46 + 2017.2.$(TunaVer) + + + + 2018 + Rvt_18 + net46 + 2018.2.$(TunaVer) + + + + 2019 + Rvt_19 + net47 + 2019.0.$(TunaVer) + + + + 2020 + Rvt_20 + net47 + 2020.0.$(TunaVer) + + + + 2021 + Rvt_21 + net48 + 2021.0.$(TunaVer) + + + + 2022 + Rvt_22 + net48 + 2022.0.$(TunaVer) + + + + 2023 + Rvt_23 + net48 + 2023.0.$(TunaVer) + + + + 2024 + Rvt_24 + net48 + 2024.0.$(TunaVer) + + + + 2025 + Rvt_25 + net8.0-windows7.0 + 2025.0.$(TunaVer) + + \ No newline at end of file diff --git a/Tuna.Revit.Extension.sln b/Tuna.Revit.Extension.sln index 3cbcf11..1c14d5a 100644 --- a/Tuna.Revit.Extension.sln +++ b/Tuna.Revit.Extension.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tuna.Revit.Extension", "src\Tuna.Revit.Extension.csproj", "{34174205-057F-4D7E-AF0A-27B3EE17552A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0CD53AF8-74E4-4F2A-BA04-DC7B0AA1CEC1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution items", "{34275DF4-26BE-4772-A596-EF731C0A66A2}" @@ -12,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution .gitignore = .gitignore LICENSE = LICENSE README.md = README.md + Tuna.Revit.Build.props = Tuna.Revit.Build.props TunaRibbon.xsd = TunaRibbon.xsd EndProjectSection EndProject @@ -27,6 +26,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{561BD9FE EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tuna.Revit.Test", "tests\Tuna.Revit.Test\Tuna.Revit.Test.csproj", "{49F3D6ED-FF71-403C-8D2B-8775A3080407}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tuna.Revit.Extension", "src\Tuna.Revit.Extension.csproj", "{F675D510-6992-4C0C-9FE9-AAB99638C7B5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -49,48 +50,10 @@ Global Rvt_23_Release|Any CPU = Rvt_23_Release|Any CPU Rvt_24_Debug|Any CPU = Rvt_24_Debug|Any CPU Rvt_24_Release|Any CPU = Rvt_24_Release|Any CPU + Rvt_25_Debug|Any CPU = Rvt_25_Debug|Any CPU + Rvt_25_Release|Any CPU = Rvt_25_Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Release|Any CPU.Build.0 = Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_16_Debug|Any CPU.ActiveCfg = Rvt_16_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_16_Debug|Any CPU.Build.0 = Rvt_16_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_16_Release|Any CPU.ActiveCfg = Rvt_16_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_16_Release|Any CPU.Build.0 = Rvt_16_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_17_Debug|Any CPU.ActiveCfg = Rvt_17_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_17_Debug|Any CPU.Build.0 = Rvt_17_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_17_Release|Any CPU.ActiveCfg = Rvt_17_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_17_Release|Any CPU.Build.0 = Rvt_17_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_18_Debug|Any CPU.ActiveCfg = Rvt_18_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_18_Debug|Any CPU.Build.0 = Rvt_18_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_18_Release|Any CPU.ActiveCfg = Rvt_18_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_18_Release|Any CPU.Build.0 = Rvt_18_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_19_Debug|Any CPU.ActiveCfg = Rvt_19_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_19_Debug|Any CPU.Build.0 = Rvt_19_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_19_Release|Any CPU.ActiveCfg = Rvt_19_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_19_Release|Any CPU.Build.0 = Rvt_19_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_20_Debug|Any CPU.ActiveCfg = Rvt_20_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_20_Debug|Any CPU.Build.0 = Rvt_20_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_20_Release|Any CPU.ActiveCfg = Rvt_20_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_20_Release|Any CPU.Build.0 = Rvt_20_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_21_Debug|Any CPU.ActiveCfg = Rvt_21_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_21_Debug|Any CPU.Build.0 = Rvt_21_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_21_Release|Any CPU.ActiveCfg = Rvt_21_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_21_Release|Any CPU.Build.0 = Rvt_21_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_22_Debug|Any CPU.ActiveCfg = Rvt_22_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_22_Debug|Any CPU.Build.0 = Rvt_22_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_22_Release|Any CPU.ActiveCfg = Rvt_22_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_22_Release|Any CPU.Build.0 = Rvt_22_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_23_Debug|Any CPU.ActiveCfg = Rvt_23_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_23_Debug|Any CPU.Build.0 = Rvt_23_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_23_Release|Any CPU.ActiveCfg = Rvt_23_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_23_Release|Any CPU.Build.0 = Rvt_23_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_24_Debug|Any CPU.ActiveCfg = Rvt_24_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_24_Debug|Any CPU.Build.0 = Rvt_24_Debug|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_24_Release|Any CPU.ActiveCfg = Rvt_24_Release|Any CPU - {34174205-057F-4D7E-AF0A-27B3EE17552A}.Rvt_24_Release|Any CPU.Build.0 = Rvt_24_Release|Any CPU {57D210DC-A989-4C3E-84E8-A40B7114052B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {57D210DC-A989-4C3E-84E8-A40B7114052B}.Debug|Any CPU.Build.0 = Debug|Any CPU {57D210DC-A989-4C3E-84E8-A40B7114052B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -122,6 +85,8 @@ Global {57D210DC-A989-4C3E-84E8-A40B7114052B}.Rvt_24_Debug|Any CPU.ActiveCfg = Rvt_24_Debug|Any CPU {57D210DC-A989-4C3E-84E8-A40B7114052B}.Rvt_24_Debug|Any CPU.Build.0 = Rvt_24_Debug|Any CPU {57D210DC-A989-4C3E-84E8-A40B7114052B}.Rvt_24_Release|Any CPU.ActiveCfg = Rvt_24_Release|Any CPU + {57D210DC-A989-4C3E-84E8-A40B7114052B}.Rvt_25_Debug|Any CPU.ActiveCfg = Rvt_24_Release|Any CPU + {57D210DC-A989-4C3E-84E8-A40B7114052B}.Rvt_25_Release|Any CPU.ActiveCfg = Rvt_24_Release|Any CPU {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Debug|Any CPU.Build.0 = Debug|Any CPU {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -138,8 +103,8 @@ Global {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_19_Debug|Any CPU.ActiveCfg = Release|Any CPU {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_19_Debug|Any CPU.Build.0 = Release|Any CPU {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_19_Release|Any CPU.ActiveCfg = Release|Any CPU - {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_20_Debug|Any CPU.ActiveCfg = Release|Any CPU - {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_20_Debug|Any CPU.Build.0 = Release|Any CPU + {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_20_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_20_Debug|Any CPU.Build.0 = Debug|Any CPU {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_20_Release|Any CPU.ActiveCfg = Release|Any CPU {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_21_Debug|Any CPU.ActiveCfg = Release|Any CPU {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_21_Debug|Any CPU.Build.0 = Release|Any CPU @@ -153,14 +118,62 @@ Global {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_24_Debug|Any CPU.ActiveCfg = Release|Any CPU {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_24_Debug|Any CPU.Build.0 = Release|Any CPU {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_24_Release|Any CPU.ActiveCfg = Release|Any CPU + {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_25_Debug|Any CPU.ActiveCfg = Release|Any CPU + {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_25_Debug|Any CPU.Build.0 = Release|Any CPU + {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_25_Release|Any CPU.ActiveCfg = Release|Any CPU + {49F3D6ED-FF71-403C-8D2B-8775A3080407}.Rvt_25_Release|Any CPU.Build.0 = Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Release|Any CPU.Build.0 = Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_16_Debug|Any CPU.ActiveCfg = Rvt_16_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_16_Debug|Any CPU.Build.0 = Rvt_16_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_16_Release|Any CPU.ActiveCfg = Rvt_16_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_16_Release|Any CPU.Build.0 = Rvt_16_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_17_Debug|Any CPU.ActiveCfg = Rvt_17_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_17_Debug|Any CPU.Build.0 = Rvt_17_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_17_Release|Any CPU.ActiveCfg = Rvt_17_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_17_Release|Any CPU.Build.0 = Rvt_17_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_18_Debug|Any CPU.ActiveCfg = Rvt_18_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_18_Debug|Any CPU.Build.0 = Rvt_18_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_18_Release|Any CPU.ActiveCfg = Rvt_18_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_18_Release|Any CPU.Build.0 = Rvt_18_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_19_Debug|Any CPU.ActiveCfg = Rvt_19_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_19_Debug|Any CPU.Build.0 = Rvt_19_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_19_Release|Any CPU.ActiveCfg = Rvt_19_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_19_Release|Any CPU.Build.0 = Rvt_19_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_20_Debug|Any CPU.ActiveCfg = Rvt_20_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_20_Debug|Any CPU.Build.0 = Rvt_20_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_20_Release|Any CPU.ActiveCfg = Rvt_20_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_20_Release|Any CPU.Build.0 = Rvt_20_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_21_Debug|Any CPU.ActiveCfg = Rvt_21_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_21_Debug|Any CPU.Build.0 = Rvt_21_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_21_Release|Any CPU.ActiveCfg = Rvt_21_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_21_Release|Any CPU.Build.0 = Rvt_21_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_22_Debug|Any CPU.ActiveCfg = Rvt_22_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_22_Debug|Any CPU.Build.0 = Rvt_22_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_22_Release|Any CPU.ActiveCfg = Rvt_22_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_22_Release|Any CPU.Build.0 = Rvt_22_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_23_Debug|Any CPU.ActiveCfg = Rvt_23_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_23_Debug|Any CPU.Build.0 = Rvt_23_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_23_Release|Any CPU.ActiveCfg = Rvt_23_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_23_Release|Any CPU.Build.0 = Rvt_23_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_24_Debug|Any CPU.ActiveCfg = Rvt_24_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_24_Debug|Any CPU.Build.0 = Rvt_24_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_24_Release|Any CPU.ActiveCfg = Rvt_24_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_24_Release|Any CPU.Build.0 = Rvt_24_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_25_Debug|Any CPU.ActiveCfg = Rvt_25_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_25_Debug|Any CPU.Build.0 = Rvt_25_Debug|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_25_Release|Any CPU.ActiveCfg = Rvt_25_Release|Any CPU + {F675D510-6992-4C0C-9FE9-AAB99638C7B5}.Rvt_25_Release|Any CPU.Build.0 = Rvt_25_Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {34174205-057F-4D7E-AF0A-27B3EE17552A} = {0CD53AF8-74E4-4F2A-BA04-DC7B0AA1CEC1} {57D210DC-A989-4C3E-84E8-A40B7114052B} = {78294CC8-0B3B-48D5-AC91-2E3C02377287} {49F3D6ED-FF71-403C-8D2B-8775A3080407} = {561BD9FE-C5B6-4817-930A-AC46291408EE} + {F675D510-6992-4C0C-9FE9-AAB99638C7B5} = {0CD53AF8-74E4-4F2A-BA04-DC7B0AA1CEC1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0F3E44F7-9014-4012-85FD-37E211988994} diff --git a/TunaRibbon.xsd b/Tuna.Revit.Ribbon.xsd similarity index 100% rename from TunaRibbon.xsd rename to Tuna.Revit.Ribbon.xsd diff --git a/sample/Tuna.Sample/Commands/SelectionCommand.cs b/sample/Tuna.Sample/Commands/SelectionCommand.cs index 1fbf60a..7a19f57 100644 --- a/sample/Tuna.Sample/Commands/SelectionCommand.cs +++ b/sample/Tuna.Sample/Commands/SelectionCommand.cs @@ -36,14 +36,14 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme uiDocument.SelectObject(Autodesk.Revit.UI.Selection.ObjectType.Element); - SelectionResult result = commandData.Application.ActiveUIDocument.SelectObject(Autodesk.Revit.UI.Selection.ObjectType.Face, + SelectionResult result = commandData.Application.ActiveUIDocument.SelectObject(Autodesk.Revit.UI.Selection.ObjectType.Face, referencePredicate: parameters => parameters.Reference.ConvertToStableRepresentation(document).Contains("SURFACE"), "asd"); - if (result.Succeeded) + if (result.SelectionStatus == SelectionStatus.Succeeded) { - + } - + commandData.Application.ActiveUIDocument.SelectObject(Autodesk.Revit.UI.Selection.ObjectType.LinkedElement, element => element.Category.Id == BuiltInCategories.Walls, "asd"); diff --git a/sample/Tuna.Sample/Tuna.Sample.csproj b/sample/Tuna.Sample/Tuna.Sample.csproj index e196d44..ed352ce 100644 --- a/sample/Tuna.Sample/Tuna.Sample.csproj +++ b/sample/Tuna.Sample/Tuna.Sample.csproj @@ -1,27 +1,11 @@  + - net48 - x64 - latest - - Debug;Release; - Rvt_16_Debug;Rvt_16_Release; - Rvt_17_Debug;Rvt_17_Release; - Rvt_18_Debug;Rvt_18_Release; - Rvt_19_Debug;Rvt_19_Release; - Rvt_20_Debug;Rvt_20_Release; - Rvt_21_Debug;Rvt_21_Release; - Rvt_22_Debug;Rvt_22_Release; - Rvt_23_Debug;Rvt_23_Release; - Rvt_24_Debug;Rvt_24_Release; - - 8 true true Program D:\Autodesk\Revit 2020\Revit.exe - diff --git a/src/Attributes/RevitDefinitionAttribute.cs b/src/Attributes/RevitDefinitionAttribute.cs index 79c3287..f15fc78 100644 --- a/src/Attributes/RevitDefinitionAttribute.cs +++ b/src/Attributes/RevitDefinitionAttribute.cs @@ -27,7 +27,12 @@ public class ExternalDefinitionAttribute : Attribute /// /// 参数所在组 /// +#if Rvt_16 || Rvt_17 || Rvt_18 || Rvt_19 || Rvt_20 || Rvt_21 || Rvt_22 || Rvt_23 public BuiltInParameterGroup ParameterGroup { get; set; } = BuiltInParameterGroup.INVALID; +#else + public ForgeTypeId ParameterGroup { get; set; } +#endif + #if Rvt_16 || Rvt_17 || Rvt_18 || Rvt_19 || Rvt_20 @@ -43,24 +48,24 @@ public ExternalDefinitionAttribute(string name, BuiltInParameterGroup builtInPar UnitType = unitType; } #else - public ExternalDefinitionAttribute(string name, BuiltInParameterGroup builtInParameterGroup) - { - Name = name; - ParameterGroup = builtInParameterGroup; - } + public ExternalDefinitionAttribute(string name, ForgeTypeId builtInParameterGroup) + { + Name = name; + ParameterGroup = builtInParameterGroup; + } #endif - /// - /// 判断两个参数是否完全一致 - /// - /// - /// - public bool Equal(Definition definition) - { - if (definition == null) return false; - if (definition.Name != Name) return false; - if (definition.ParameterGroup != ParameterGroup) return false; -#if Rvt_16 || Rvt_17|| Rvt_18|| Rvt_19|| Rvt_20 + /// + /// 判断两个参数是否完全一致 + /// + /// + /// + public bool Equal(Definition definition) + { + if (definition == null) return false; + if (definition.Name != Name) return false; + if (definition.GetGroupTypeId() != ParameterGroup) return false; +#if Rvt_16 || Rvt_17 || Rvt_18 || Rvt_19 || Rvt_20 if (definition.ParameterType != ParameterType) return false; if (definition.UnitType != UnitType) return false; #endif diff --git a/src/Geometry/GeometryExtensions.cs b/src/Geometry/GeometryExtensions.cs index 0d47a79..af095d9 100644 --- a/src/Geometry/GeometryExtensions.cs +++ b/src/Geometry/GeometryExtensions.cs @@ -1,12 +1,21 @@ -using Autodesk.Revit.DB; +/************************************************************************************ + Author:十五 + CretaeTime: + Mail:1012201478@qq.com + Github:https://github.com/shichuyibushishiwu + + Description: + +************************************************************************************/ + +using Autodesk.Revit.DB; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Tuna.Revit.Extension.Geometry; - +namespace Tuna.Revit.Extension; /// /// 图形扩展 @@ -40,29 +49,8 @@ private static List ResolveGeometry(this GeometryElement geometr case GeometryElement geometryElement: objects.AddRange(ResolveGeometry(geometryElement)); break; - case Curve curve: - objects.Add(curve); - break; - case Edge edge: - objects.Add(edge); - break; - case Face face: - objects.Add(face); - break; - case Mesh mesh: - objects.Add(mesh); - break; - case Point point: - objects.Add(point); - break; - case PolyLine polyLine: - objects.Add(polyLine); - break; - case Profile profile: - objects.Add(profile); - break; - case Solid solid: - objects.Add(solid); + default: + objects.Add(item); break; } } diff --git a/src/Selection/SelectionExtension.cs b/src/Selection/SelectionExtension.cs index 395710e..7df83db 100644 --- a/src/Selection/SelectionExtension.cs +++ b/src/Selection/SelectionExtension.cs @@ -46,20 +46,21 @@ public static SelectionResult SelectObject(this UIDocument uiDocument ? uiDocument.Selection.PickObject(objectType, selectionFilter) : uiDocument.Selection.PickObject(objectType, selectionFilter, prompt); - selectionResult.Succeeded = true; + selectionResult.SelectionStatus = SelectionStatus.Succeeded; selectionResult.Message = "Succeeded"; } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { - selectionResult.Succeeded = false; + selectionResult.SelectionStatus = SelectionStatus.Cancelled; selectionResult.Message = "Canceled"; } catch (Exception exception) { - selectionResult.Succeeded = false; + selectionResult.SelectionStatus = SelectionStatus.Failed; selectionResult.Message = exception.Message; - throw exception; + selectionResult.Exception = exception; } + return selectionResult; } @@ -120,8 +121,8 @@ public static SelectionResult SelectElement(this UIDocument uiDocument, return new SelectionResult() { Message = result.Message, - Succeeded = result.Succeeded, - Value = result.Succeeded ? uiDocument.Document.GetElement(result.Value) : default(Element) + SelectionStatus = result.SelectionStatus, + Value = result.SelectionStatus == SelectionStatus.Succeeded ? uiDocument.Document.GetElement(result.Value) : default }; } @@ -163,6 +164,41 @@ public static SelectionResult SelectElement(this UIDocument uiDocument, return uiDocument.SelectElement(_ => true, prompt); } + /// + /// 当前方法用于提示用户选择图元,如果用户取消了操作(比如用户按下 ESC),那么将会返回一个失败的结果,即 的属性 Succeeded 将为false,反之,为true + /// Prompts the user to select one object , if the user cancels the operation (for example, through ESC), the method will return failed result. otherwise true + /// + /// + /// 要操作的文档 + /// 给用户的提示 + /// + /// + public static SelectionResult SelectElement(this UIDocument uiDocument, Func elementPredicate = null, string prompt = null) where T : Element + { + SelectionResult result = uiDocument.SelectElement(element => + { + if (element is not T targetElement) + { + return false; + } + + if (elementPredicate != null) + { + return elementPredicate(targetElement); + } + + return true; + }, prompt); + + return new SelectionResult() + { + Exception = result.Exception, + Message = result.Message, + SelectionStatus = result.SelectionStatus, + Value = result.SelectionStatus == SelectionStatus.Succeeded ? result.Value as T : default + }; + } + /// /// 当前方法用于提示用户选择多个对象,如果用户取消了操作(比如用户按下 ESC),那么将会返回一个失败的结果,即 的属性 Succeeded 将为false,反之,为true /// Prompts the user to select multiple objects , if the user cancels the operation (for example, through ESC), the method will return failed result. otherwise true @@ -188,17 +224,18 @@ public static SelectionResult> SelectObjects(this UIDocument ui : uiDocument.Selection.PickObjects(objectType, selectionFilter, prompt); selectionResult.Message = "Succeeded"; + selectionResult.SelectionStatus = SelectionStatus.Succeeded; } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { - selectionResult.Succeeded = false; + selectionResult.SelectionStatus = SelectionStatus.Cancelled; selectionResult.Message = "Canceled"; } catch (Exception exception) { - selectionResult.Succeeded = false; + selectionResult.SelectionStatus = SelectionStatus.Failed; selectionResult.Message = exception.Message; - throw exception; + selectionResult.Exception = exception; } return selectionResult; @@ -226,18 +263,20 @@ public static SelectionResult> SelectObjects(this UIDocument ui { selectionFilter ??= new DefaultSelectionFilter(); uiDocument.Selection.PickObjects(objectType, selectionFilter, prompt, pPreSelected); + selectionResult.Message = "Succeeded"; + selectionResult.SelectionStatus = SelectionStatus.Succeeded; } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { - selectionResult.Succeeded = false; + selectionResult.SelectionStatus = SelectionStatus.Cancelled; selectionResult.Message = "Canceled"; } catch (Exception exception) { - selectionResult.Succeeded = false; + selectionResult.SelectionStatus = SelectionStatus.Failed; selectionResult.Message = exception.Message; - throw exception; + selectionResult.Exception = exception; } return selectionResult; @@ -300,8 +339,8 @@ public static SelectionResult> SelectElements(this UIDocume return new SelectionResult>() { Message = result.Message, - Succeeded = result.Succeeded, - Value = result.Succeeded ? result.Value.Select(reference => uiDocument.Document.GetElement(reference)) : Enumerable.Empty() + SelectionStatus = result.SelectionStatus, + Value = result.SelectionStatus == SelectionStatus.Succeeded ? result.Value.Select(reference => uiDocument.Document.GetElement(reference)) : Enumerable.Empty() }; } @@ -311,11 +350,25 @@ public static SelectionResult> SelectElements(this UIDocume /// /// 要操作的文档 /// 要选择的图元类型 + /// 对要选择的引用进行筛选 /// 给用户的提示 /// 用户选择的结果 - public static SelectionResult> SelectElements(this UIDocument uiDocument, Type type, string prompt = null) + public static SelectionResult> SelectElements(this UIDocument uiDocument, Type type, Func elementPredicate = null, string prompt = null) { - return uiDocument.SelectElements(e => e.GetType() == type, prompt); + return uiDocument.SelectElements(e => + { + if (e.GetType() != type) + { + return false; + } + + if (elementPredicate != null) + { + return elementPredicate(e); + } + + return true; + }, prompt); } /// @@ -323,11 +376,33 @@ public static SelectionResult> SelectElements(this UIDocume /// Prompts the user to select multiple objects , if the user cancels the operation (for example, through ESC), the method will return failed result. otherwise true /// /// 要操作的文档 + /// 对要选择的引用进行筛选 /// 给用户的提示 /// 用户选择的结果 - public static SelectionResult> SelectElements(this UIDocument uiDocument, string prompt = null) where T : Element + public static SelectionResult> SelectElements(this UIDocument uiDocument, Func elementPredicate = null, string prompt = null) where T : Element { - return uiDocument.SelectElements(typeof(T), prompt); + SelectionResult> result = uiDocument.SelectElements(element => + { + if (element is not T targetElement) + { + return false; + } + + if (elementPredicate != null) + { + return elementPredicate(targetElement); + } + + return true; + }, prompt); + + return new SelectionResult>() + { + Exception = result.Exception, + Message = result.Message, + SelectionStatus = result.SelectionStatus, + Value = result.SelectionStatus == SelectionStatus.Succeeded ? result.Value.Cast() : Enumerable.Empty() + }; } /// @@ -385,19 +460,19 @@ public static SelectionResult SelectPoint(this UIDocument uiDocument, Objec ? uiDocument.Selection.PickPoint(snapTypes) : uiDocument.Selection.PickPoint(snapTypes, prompt); - result.Succeeded = true; + result.SelectionStatus = SelectionStatus.Succeeded; result.Message = "Succeeded"; } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { - result.Succeeded = false; + result.SelectionStatus = SelectionStatus.Cancelled; result.Message = "Canceled"; } catch (Exception e) { - result.Succeeded = false; + result.SelectionStatus = SelectionStatus.Failed; result.Message = e.Message; - throw e; + result.Exception = e; } return result; } @@ -418,19 +493,19 @@ public static SelectionResult SelectPoint(this UIDocument uiDocument, strin ? uiDocument.Selection.PickPoint() : uiDocument.Selection.PickPoint(prompt); - result.Succeeded = true; + result.SelectionStatus = SelectionStatus.Succeeded; result.Message = "Succeeded"; } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { - result.Succeeded = false; + result.SelectionStatus = SelectionStatus.Cancelled; result.Message = "Canceled"; } - catch (Exception e) + catch (Exception exception) { - result.Succeeded = false; - result.Message = e.Message; - throw e; + result.SelectionStatus = SelectionStatus.Failed; + result.Message = exception.Message; + result.Exception = exception; } return result; } @@ -454,19 +529,19 @@ public static SelectionResult> SelectElementsByRectangle(this UID ? uiDocument.Selection.PickElementsByRectangle(selectionFilter) : uiDocument.Selection.PickElementsByRectangle(selectionFilter, prompt); - selectionResult.Succeeded = true; + selectionResult.SelectionStatus = SelectionStatus.Succeeded; selectionResult.Message = "Succeeded"; } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { - selectionResult.Succeeded = false; + selectionResult.SelectionStatus = SelectionStatus.Cancelled; selectionResult.Message = "Canceled"; } catch (Exception exception) { - selectionResult.Succeeded = false; + selectionResult.SelectionStatus = SelectionStatus.Failed; selectionResult.Message = exception.Message; - throw exception; + selectionResult.Exception = exception; } return selectionResult; @@ -537,20 +612,20 @@ public static SelectionResult SelectBox(this UIDocument uIDocument, P { PickedBox pickBox = string.IsNullOrWhiteSpace(prompt) ? uIDocument.Selection.PickBox(pickBoxStyle) : uIDocument.Selection.PickBox(pickBoxStyle, prompt); - selectionResult.Succeeded = true; + selectionResult.SelectionStatus = SelectionStatus.Succeeded; selectionResult.Message = "Succeeded"; selectionResult.Value = pickBox; } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { - selectionResult.Succeeded = false; + selectionResult.SelectionStatus = SelectionStatus.Cancelled; selectionResult.Message = "Canceled"; } catch (Exception exception) { - selectionResult.Succeeded = false; - selectionResult.Message = "Canceled"; - throw exception; + selectionResult.SelectionStatus = SelectionStatus.Failed; + selectionResult.Message = exception.Message; + selectionResult.Exception = exception; } return selectionResult; diff --git a/src/Selection/SelectionResult.cs b/src/Selection/SelectionResult.cs index 6c3defd..31389f0 100644 --- a/src/Selection/SelectionResult.cs +++ b/src/Selection/SelectionResult.cs @@ -8,6 +8,9 @@ ************************************************************************************/ +using System; +using Tuna.Revit.Extension; + namespace Tuna.Revit.Extension; /// @@ -17,14 +20,6 @@ namespace Tuna.Revit.Extension; /// public class SelectionResult { - /// - /// succeeded - /// - public SelectionResult() - { - Succeeded = true; - } - /// /// message /// @@ -38,5 +33,15 @@ public SelectionResult() /// /// selction state /// - public bool Succeeded { get; set; } + public SelectionStatus SelectionStatus { get; set; } + + /// + /// exception + /// + public Exception Exception { get; set; } + + /// + /// Has exception + /// + public bool HasException => Exception != null; } diff --git a/src/Selection/SelectionStatus.cs b/src/Selection/SelectionStatus.cs new file mode 100644 index 0000000..3e5b046 --- /dev/null +++ b/src/Selection/SelectionStatus.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tuna.Revit.Extension; + +/// +/// 用户选择的状态 +/// +public enum SelectionStatus +{ + Succeeded, + Failed, + Cancelled +} diff --git a/src/TestCommand.cs b/src/TestCommand.cs index 9a55e8a..79ed723 100644 --- a/src/TestCommand.cs +++ b/src/TestCommand.cs @@ -27,11 +27,12 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme { new Reference(document.GetElement(new ElementId(2312))) }); - if (result.Succeeded) + + if (result.SelectionStatus == SelectionStatus.Succeeded) { foreach (var item in result.Value) { - System.Windows.MessageBox.Show(item.ElementId.ToString()); + } } diff --git a/src/Transaction/SubTransactionExtensions.cs b/src/Transaction/SubTransactionExtensions.cs index 7317f5c..dd2dff0 100644 --- a/src/Transaction/SubTransactionExtensions.cs +++ b/src/Transaction/SubTransactionExtensions.cs @@ -48,19 +48,16 @@ public static TransactionResult NewSubtransaction(this Document document, Action result.TransactionStatus = transaction.Commit(); return result; } - catch (TransactionRollbackException exception) - { - result.TransactionStatus = transaction.RollBack(); - result.Message = exception.Message; - return result; - } catch (Exception exception) { - result.Exception = exception; result.Message = exception.Message; result.TransactionStatus = transaction.RollBack(); - throw exception; + if (exception.GetType() != typeof(TransactionRollbackException)) + { + result.Exception = exception; + } } } + return result; } } diff --git a/src/Transaction/TransactionExtensions.cs b/src/Transaction/TransactionExtensions.cs index eb9c8bd..0d02353 100644 --- a/src/Transaction/TransactionExtensions.cs +++ b/src/Transaction/TransactionExtensions.cs @@ -49,20 +49,18 @@ public static TransactionResult NewTransaction(this Document document, Action diff --git a/src/Transaction/TransactionGroupExtensions.cs b/src/Transaction/TransactionGroupExtensions.cs index 77bdd0f..6ff5a21 100644 --- a/src/Transaction/TransactionGroupExtensions.cs +++ b/src/Transaction/TransactionGroupExtensions.cs @@ -46,20 +46,18 @@ public static TransactionResult NewTransactionGroup(this Document document, Acti result.TransactionStatus = options.IsMerge ? tsg.Assimilate() : tsg.Commit(); return result; } - catch (TransactionRollbackException exception) - { - result.TransactionStatus = tsg.RollBack(); - result.Message = exception.Message; - return result; - } catch (Exception exception) { - result.Exception = exception; result.Message = exception.Message; result.TransactionStatus = tsg.RollBack(); - throw exception; + if (exception.GetType() != typeof(TransactionRollbackException)) + { + result.Exception = exception; + } } } + + return result; } /// diff --git a/src/Transaction/TransactionResult.cs b/src/Transaction/TransactionResult.cs index ad8ee5f..db99b1c 100644 --- a/src/Transaction/TransactionResult.cs +++ b/src/Transaction/TransactionResult.cs @@ -26,4 +26,10 @@ public class TransactionResult /// 事务的状态 /// public TransactionStatus TransactionStatus { get; set; } + + /// + /// 是否存在未知的异常 + /// Has exception + /// + public bool HasException => Exception != null; } diff --git a/src/Transaction/TransactionRollbackException.cs b/src/Transaction/TransactionRollbackException.cs index ecc3f2e..71261a9 100644 --- a/src/Transaction/TransactionRollbackException.cs +++ b/src/Transaction/TransactionRollbackException.cs @@ -17,5 +17,5 @@ public class TransactionRollbackException : Exception /// Initialize a friendly exception to roll back transaction /// /// - public TransactionRollbackException(string message = null) : base(message) { } + public TransactionRollbackException(string message = "Rollback") : base(message) { } } diff --git a/src/Tuna.Revit.Extension.csproj b/src/Tuna.Revit.Extension.csproj index 186b6e8..16bf10e 100644 --- a/src/Tuna.Revit.Extension.csproj +++ b/src/Tuna.Revit.Extension.csproj @@ -1,29 +1,15 @@  + + - net48 Library True - true - preview true - x64 - - Debug;Release; - Rvt_16_Debug;Rvt_16_Release; - Rvt_17_Debug;Rvt_17_Release; - Rvt_18_Debug;Rvt_18_Release; - Rvt_19_Debug;Rvt_19_Release; - Rvt_20_Debug;Rvt_20_Release; - Rvt_21_Debug;Rvt_21_Release; - Rvt_22_Debug;Rvt_22_Release; - Rvt_23_Debug;Rvt_23_Release; - Rvt_24_Debug;Rvt_24_Release; - + true True Tuna Shiwu Tuna.png - 14 README.md This is an extensions package for revit api. https://github.com/shichuyibushishiwu/Tuna.Revit.Extensions/wiki @@ -33,68 +19,7 @@ MIT - - 2016 - Rvt_16 - net452 - 2016.2.$(TunaVer) - - - - 2017 - Rvt_17 - net46 - 2017.2.$(TunaVer) - - - - 2018 - Rvt_18 - net46 - 2018.2.$(TunaVer) - - - - 2019 - Rvt_19 - net47 - 2019.0.$(TunaVer) - - - - 2020 - Rvt_20 - net47 - 2020.0.$(TunaVer) - - - - 2021 - Rvt_21 - net48 - 2021.0.$(TunaVer) - - - - 2022 - Rvt_22 - net48 - 2022.0.$(TunaVer) - - - - 2023 - Rvt_23 - net48 - 2023.0.$(TunaVer) - - - - 2024 - Rvt_24 - net48 - 2024.0.$(TunaVer) - + True @@ -185,6 +110,12 @@ compile + + + compile + + + @@ -196,10 +127,10 @@ - + diff --git a/tests/Tuna.Revit.Test/Tuna.Revit.Test.csproj b/tests/Tuna.Revit.Test/Tuna.Revit.Test.csproj index 6ef68d7..ec51dff 100644 --- a/tests/Tuna.Revit.Test/Tuna.Revit.Test.csproj +++ b/tests/Tuna.Revit.Test/Tuna.Revit.Test.csproj @@ -17,8 +17,4 @@ - - - - diff --git a/tests/Tuna.Revit.Test/UnitTest1.cs b/tests/Tuna.Revit.Test/UnitTest1.cs index 15c2df5..c198bc6 100644 --- a/tests/Tuna.Revit.Test/UnitTest1.cs +++ b/tests/Tuna.Revit.Test/UnitTest1.cs @@ -7,12 +7,7 @@ public class Tests [Test] public void RangeInt() { - var result = Extension.Enumerator.Range(0,-1,-0.1); - foreach (var item in result) - { - - } - Assert.Pass(); + } } } \ No newline at end of file