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

Storing parameters in SOLIDWORKS macro feature


Parameters are any additional metadata required by the macro feature. Currently only primitive types of parameters are supported (i.e. string, bool, double, int etc.)

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

namespace Xarial.XCad.Documentation
{
    public class MacroFeaturePrimitiveParams
    {
        public string Parameter1 { get; set; }
        public int Parameter2 { get; set; }
    }

    //this macro feature has two parameters (Parameter1 and Parameter2)
    [ComVisible(true)]
    public class PrimitiveParametersMacroFeature : SwMacroFeatureDefinition<MacroFeaturePrimitiveParams>
    {
        public override CustomFeatureRebuildResult OnRebuild(ISwApplication app, ISwDocument model,
            ISwMacroFeature<MacroFeaturePrimitiveParams> feature, out AlignDimensionDelegate<MacroFeaturePrimitiveParams> alignDim)
        {
            alignDim = null;
            return new CustomFeatureRebuildResult();
        }
    }
}


Powered by Docify