XCAD.NET
XCAD.NET
Framework for .NET (C# and VB.NET) to create modern application for CAD systems (SOLIDWORKS, SOLIDWORKS Document Manager, Autodesk Inventor, etc.)
Get technical support Connect to xCAD community on Discord server Explore code and application examples xCAD.NET Templates for Visual Studio and VS Code Access source code

Handling the SOLIDWORKS macro feature state update in xCAD framework


This handler is called every time state of the feature is changed. It should be used to provide additional security for macro feature.

using System.Runtime.InteropServices;
using Xarial.XCad.Features.CustomFeature.Enums;
using Xarial.XCad.SolidWorks;
using Xarial.XCad.SolidWorks.Documents;
using Xarial.XCad.SolidWorks.Features.CustomFeature;

namespace Xarial.XCad.Documentation
{
    [ComVisible(true)]
    public class UpdateStateMacroFeature : SwMacroFeatureDefinition
    {
        public override CustomFeatureState_e OnUpdateState(ISwApplication app, ISwDocument model, ISwMacroFeature feature)
        {
            //disallow editing or suppressing of the feature
            return CustomFeatureState_e.CannotBeDeleted 
                | CustomFeatureState_e.CannotBeSuppressed;
        }
    }
}


Powered by Docify