| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace SolidEdgeCommunity.Extensions; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// SolidEdgeFramework.Environment extension methods. |
| | | 7 | | /// </summary> |
| | | 8 | | public static class EnvironmentExtensions |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Returns a Guid representing the environment category. |
| | | 12 | | /// </summary> |
| | 25 | 13 | | public static Guid GetCategoryId(this Environment environment) => new(environment.CATID); |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Returns a Type representing the corresponding command constants for a particular environment. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <param name="environment"></param> |
| | | 19 | | /// <returns></returns> |
| | | 20 | | public static Type GetCommandConstantType(this Environment environment) |
| | | 21 | | { |
| | 23 | 22 | | var categoryId = environment.GetCategoryId(); |
| | | 23 | | |
| | 23 | 24 | | if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Application)) |
| | | 25 | | { |
| | 1 | 26 | | return typeof(SolidEdgeConstants.SolidEdgeCommandConstants); |
| | | 27 | | } |
| | 22 | 28 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Assembly)) |
| | | 29 | | { |
| | 1 | 30 | | return typeof(AssemblyCommandConstants); |
| | | 31 | | } |
| | 21 | 32 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DMAssembly)) |
| | | 33 | | { |
| | 1 | 34 | | return typeof(AssemblyCommandConstants); |
| | | 35 | | } |
| | 20 | 36 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.CuttingPlaneLine)) |
| | | 37 | | { |
| | 1 | 38 | | return typeof(CuttingPlaneLineCommandConstants); |
| | | 39 | | } |
| | 19 | 40 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Draft)) |
| | | 41 | | { |
| | 1 | 42 | | return typeof(DetailCommandConstants); |
| | | 43 | | } |
| | 18 | 44 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DrawingViewEdit)) |
| | | 45 | | { |
| | 1 | 46 | | return typeof(DrawingViewEditCommandConstants); |
| | | 47 | | } |
| | 17 | 48 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Explode)) |
| | | 49 | | { |
| | 1 | 50 | | return typeof(ExplodeCommandConstants); |
| | | 51 | | } |
| | 16 | 52 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Layout)) |
| | | 53 | | { |
| | 1 | 54 | | return typeof(LayoutCommandConstants); |
| | | 55 | | } |
| | 15 | 56 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Sketch)) |
| | | 57 | | { |
| | 1 | 58 | | return typeof(LayoutInPartCommandConstants); |
| | | 59 | | } |
| | 14 | 60 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Motion)) |
| | | 61 | | { |
| | 1 | 62 | | return typeof(MotionCommandConstants); |
| | | 63 | | } |
| | 13 | 64 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Part)) |
| | | 65 | | { |
| | 1 | 66 | | return typeof(PartCommandConstants); |
| | | 67 | | } |
| | 12 | 68 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DMPart)) |
| | | 69 | | { |
| | 1 | 70 | | return typeof(PartCommandConstants); |
| | | 71 | | } |
| | 11 | 72 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Profile)) |
| | | 73 | | { |
| | 1 | 74 | | return typeof(ProfileCommandConstants); |
| | | 75 | | } |
| | 10 | 76 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.ProfileHole)) |
| | | 77 | | { |
| | 1 | 78 | | return typeof(ProfileHoleCommandConstants); |
| | | 79 | | } |
| | 9 | 80 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.ProfilePattern)) |
| | | 81 | | { |
| | 1 | 82 | | return typeof(ProfilePatternCommandConstants); |
| | | 83 | | } |
| | 8 | 84 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.ProfileRevolved)) |
| | | 85 | | { |
| | 1 | 86 | | return typeof(ProfileRevolvedCommandConstants); |
| | | 87 | | } |
| | 7 | 88 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.SheetMetal)) |
| | | 89 | | { |
| | 1 | 90 | | return typeof(SheetMetalCommandConstants); |
| | | 91 | | } |
| | 6 | 92 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DMSheetMetal)) |
| | | 93 | | { |
| | 1 | 94 | | return typeof(SheetMetalCommandConstants); |
| | | 95 | | } |
| | 5 | 96 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Simplify)) |
| | | 97 | | { |
| | 1 | 98 | | return typeof(SimplifyCommandConstants); |
| | | 99 | | } |
| | 4 | 100 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Studio)) |
| | | 101 | | { |
| | 1 | 102 | | return typeof(StudioCommandConstants); |
| | | 103 | | } |
| | 3 | 104 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.XpresRoute)) |
| | | 105 | | { |
| | 1 | 106 | | return typeof(TubingCommandConstants); |
| | | 107 | | } |
| | 2 | 108 | | else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Weldment)) |
| | | 109 | | { |
| | 1 | 110 | | return typeof(WeldmentCommandConstants); |
| | | 111 | | } |
| | | 112 | | |
| | 1 | 113 | | return null; |
| | | 114 | | } |
| | | 115 | | |
| | | 116 | | /// <summary> |
| | | 117 | | /// Returns a SolidEdgeFramework.Environment by name. |
| | | 118 | | /// </summary> |
| | | 119 | | public static Environment LookupByName(this Environments environments, string name) |
| | | 120 | | { |
| | 6 | 121 | | for (int i = 1; i <= environments.Count; i++) |
| | | 122 | | { |
| | 2 | 123 | | var environment = environments.Item(i); |
| | 2 | 124 | | if (environment.Name.Equals(name)) |
| | | 125 | | { |
| | 1 | 126 | | return environment; |
| | | 127 | | } |
| | | 128 | | } |
| | | 129 | | |
| | 1 | 130 | | return null; |
| | | 131 | | } |
| | | 132 | | |
| | | 133 | | /// <summary> |
| | | 134 | | /// Returns a SolidEdgeFramework.Environment by category id.. |
| | | 135 | | /// </summary> |
| | | 136 | | public static Environment LookupByCategoryId(this Environments environments, Guid categoryId) |
| | | 137 | | { |
| | 2 | 138 | | for (int i = 1; i <= environments.Count; i++) |
| | | 139 | | { |
| | 1 | 140 | | var environment = environments.Item(i); |
| | 1 | 141 | | if (environment.GetCategoryId().Equals(categoryId)) |
| | | 142 | | { |
| | 1 | 143 | | return environment; |
| | | 144 | | } |
| | | 145 | | } |
| | | 146 | | |
| | 0 | 147 | | return null; |
| | | 148 | | } |
| | | 149 | | } |