Search code examples
c#solidworks

Solidworks API C# / VB.net set Enum property


The Solidworks eDrawings API lists the following

EnableFeature Property (IEModelViewControl)

Visual Basic (Usage)

 Dim instance As IEModelViewControl
 Dim feature As EMVEnableFeatures
 Dim value As System.Boolean

 instance.EnableFeature(feature) = value

 value = instance.EnableFeature(feature)

Solidworks provides an "example" solution (C#.NET) for which the following is the control

this.eDrawingControl1 = new eDrawingHostControl.eDrawingControl();

Looking into the eDrawingHost.eDrawingControl namespace we can see

 public EModelViewControl eDrawingControlWrapper { get; }

So I would think

eDrawingControl1.eDrawingControlWrapper.EnableFeature(feature) = true;

would work, but instead I get

Non-invocable member 'IEModelViewControl.EnableFeature[EMVEnableFeatures]' cannot be used like a method.

As proof the instance is OK and working properly, something like

eDrawingControl1.eDrawingControlWrapper.Save(@"filePath", false,"");

works perfectly fine.

Am I misunderstanding the C# syntax for setting such a (enum) property?


Solution

  • Looks like their wrapper is using a named indexer, something you can't do in C#. You can however consume it from C#:

    eDrawingControl1.eDrawingControlWrapper.EnableFeature[feature] = true;