Posts

Showing posts from October, 2018

To select the last created plane

To select by using SolidWorks API / Macro to select the last plane on the Feature Manager tree Dim swApp As SldWorks.SldWorks Dim swmodel As SldWorks.ModelDoc2 Dim swfeat As SldWorks.Feature Dim var As Variant Dim swfeatmgr As SldWorks.FeatureManager Dim n As Integer Dim plan As Variant Dim swplan As SldWorks.Feature Dim bool As Boolean Sub main() Set swApp = Application.SldWorks Set swmodel = swApp.ActiveDoc Set swfeatmgr = swmodel.FeatureManager var = swfeatmgr.GetFeatures(False) For i = 0 To UBound(var) Set swfeat = var(i) If swfeat.GetTypeName2 = "RefPlane" Then n = i Debug.Print swfeat.Name & "  " & swfeat.GetTypeName2 End If Next bool = var(n).Select2(False, 0) End Sub

To delete every configuration except the active one

SolidWorks API Macro to delete every configuration except the active one. Please find the macro for the same. Dim swApp As SldWorks.SldWorks Dim swmodel As SldWorks.ModelDoc2 Dim swconfig As SldWorks.Configuration Dim vconfig As Variant Dim conName As String Dim Sconfig As String Dim bool As Boolean Sub main() Set swApp = Application.SldWorks Set swmodel = swApp.ActiveDoc vconfig = swmodel.GetConfigurationNames Set swconfig = swmodel.GetActiveConfiguration conName = swconfig.Name vconfig = swmodel.GetConfigurationNames For i = 0 To UBound(vconfig) Sconfig = vconfig(i) If Not config = conName Then bool = swmodel.DeleteConfiguration2(vconfig(i)) End If Next End Sub

SolidWorks API Macro to check Compare balloons with BOM

 This macro helps to identify if every balloons has been insert in relevance to the BOM in the first page.When you run the Macro, The missed out item will be shown in the Listbox. Click here for the Macro