ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
CBCasey Balderson12/12/2018

I have a series of Library Feature Parts that I would like to assign to buttons in the Command Manager under a custom tab. This is because the Design Library itself is so overwhelmed with folder structure, that it doesn't make sense to bury it in there. Also, I intend to convert these into Macro Features in the future, so having the buttons already assigned and visible would be an easy transition in the future as well (once I get more comfortable with Macro Features).

It doesn't seem that the "Record Macro" gives me any useful information, as just opens the library feature part, and does nothing with it.

As of now, by VBA code generates the LFP, but chooses the settings automatically based on last saved. I want the Property Manager to show and allow you to choose the placement plane, configuration, and references.

Option Explicit

Option Compare Text

Sub main()

    Dim myFeat As Feature

    Dim myEnt As Entity

    Dim mySelectData As SelectData

    Dim selMgr As SelectionMgr

    Dim libPart As ModelDoc2

    Dim myLibFile As String

    Dim swApp As SldWorks.SldWorks

    Dim Part As ModelDoc2

    Dim myPart As PartDoc

    Dim longstatus As Long, longwarnings As Long

    Dim boolStatus As Boolean

  

    myLibFile = "C:\Users\cbalderson\Desktop\lib\BEAD_20DEG.SLDLFP"

    Set swApp = Application.SldWorks

  

    Set Part = swApp.ActiveDoc

    boolStatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

   

    Part.InsertLibraryFeature myLibFile

End Sub

PS. I referenced " " for the code I have now.