XCAD.NET
XCAD.NET
Framework for .NET (C# and VB.NET) to create modern application for CAD systems (SOLIDWORKS)
Get technical support Access source code Explore code and application examples

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 feature, MacroFeaturePrimitiveParams parameters, out AlignDimensionDelegate<MacroFeaturePrimitiveParams> alignDim)
        {
            alignDim = null;
            return new CustomFeatureRebuildResult();
        }
    }
}


Powered by Docify