Closed JulienMalbault closed 2 years ago
I create a macrofeature with selection property. Selection works, but when I validate the macroFeature, it doesn't add it in the tree.
Output : Exception levée : 'System.PlatformNotSupportedException' dans System.Private.CoreLib.dll
This is my code:
` [System.Runtime.InteropServices.ComVisible(true)] [Guid("F75B5CE9-D170-4394-8EDA-E1C703E661C0")] [ProgId("766E069B - 9D91 - 4B23 - 9C19 - 5D0B50DB7EA6")] [DisplayName("SWAddInJM")] public class AddInJM : Xarial.XCad.SolidWorks.SwAddInEx { public enum SourceCommands_e { StartFeature }
[ComRegisterFunction] public static void RegisterFunction(Type t) { SwAddInEx.RegisterFunction(t); } [ComUnregisterFunction] public static void UnregisterFunction(Type t) { SwAddInEx.RegisterFunction(t); } public override void OnConnect() { m_Data = new ModelDataPage(); m_Page = this.CreatePage<ModelDataPage>(); this.CommandManager.AddCommandGroup<SourceCommands_e>().CommandClick += OnCommandClick; } private ISwPropertyManagerPage<ModelDataPage> m_Page; private ModelDataPage m_Data; private void OnCommandClick(SourceCommands_e cmd) { switch (cmd) { case SourceCommands_e.StartFeature: this.Application.Documents.Active.Features.CreateCustomFeature<MacroFeatureDef, ModelDataPage, ModelDataPage>(); break; } } } [Guid("DE872A86-7E3A-4522-B29B-8E97B3A96E02")] [ComVisible(true)] public class MacroFeatureDef : SwMacroFeatureDefinition<ModelDataPage, ModelDataPage> { public override ISwBody[] CreateGeometry(ISwApplication app, ISwDocument model, ModelDataPage data, bool isPreview, out AlignDimensionDelegate<ModelDataPage> alignDim) { ISwPart part = model as ISwPart; alignDim = null; return part.Bodies.Select(x => (ISwBody)x).ToArray(); } } [Guid("67674BB7-7834-48AD-8380-63682FCD7821")] [ComVisible(true)] public class ModelDataPage : SwPropertyManagerPageHandler { [SelectionBoxOptions(SelectType_e.Dimensions)] public ISwSelObject Dispatch { get; set; } }
`
CreateGeometry should only return temp bodies (or operations between permanent (edit bodies) and temp bodies. It should not return bodies which are not edited bodies. Here is example
I create a macrofeature with selection property. Selection works, but when I validate the macroFeature, it doesn't add it in the tree.
Output : Exception levée : 'System.PlatformNotSupportedException' dans System.Private.CoreLib.dll
This is my code:
` [System.Runtime.InteropServices.ComVisible(true)] [Guid("F75B5CE9-D170-4394-8EDA-E1C703E661C0")] [ProgId("766E069B - 9D91 - 4B23 - 9C19 - 5D0B50DB7EA6")] [DisplayName("SWAddInJM")] public class AddInJM : Xarial.XCad.SolidWorks.SwAddInEx { public enum SourceCommands_e { StartFeature }
`