I am trying to create a macro feature a using VB.NET addin and am not having much luck. I have tried both the COM callbacks and .NET add-In callbacks methods described here as well as using some examples I found poking around the form. I am very familiar with making macro features as a VBA macro so I'm guessing there is something that I am unaware of when using .net so hopefully this is easy question.
The code below is just what i have been using to just try and get a feature inserted so there shouldn't be anything else causing an issue. I have the following module and class in separate .vb files in a project called MyProject, which is also the Start Up Project in a Solution. I have actually tried using InsertMacroFeature3 from an addin but know luck with that either.
Public Module MyModule
Public Sub Main()
Dim _app As SldWorks = GetObject(, "SldWorks.Application")
Dim _model As ModelDoc2 = _app.ActiveDoc
Dim FeatMgr As FeatureManager = _model.FeatureManager
Dim feat As Feature = FeatMgr.InsertMacroFeature3("TestFeature", "MyProject.MacroFeatureClass", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, swMacroFeatureOptions_e.swMacroFeatureByDefault)
If feat Is Nothing Then MsgBox("Macro Feature Failure")
<ComClass(MacroFeatureClass.ClassId, MacroFeatureClass.InterfaceId, MacroFeatureClass.EventsId)>
Public Class MacroFeatureClass
Public Const ClassId As String = "1FEC45A4-8300-4FD2-AFC4-ED4952A6F4F5"
Public Const InterfaceId As String = "19DEA4FB-46F6-445D-B996-39BACD9B70CA"
Public Const EventsId As String = "8AF8B870-7455-431C-B5F2-718CCCA1607C"
Public Sub New()
Public Function Rebuild(ByVal app As Object, ByVal model As Object, ByVal feat As Object) As Object Implements ISwComFeature.Regenerate
Public Function Edit(ByVal app As Object, ByVal model As Object, ByVal feat As Object) As Object Implements ISwComFeature.Edit
Public Function Security(ByVal app As Object, ByVal model As Object, ByVal feat As Object) As Object Implements ISwComFeature.Security