I have an assembly with some sub assemblies within its tree structure. I want to add custom properties to each of those sub assemblies using property tab builder. How can I do that?
Property Tab Builder only allows edits to the custom properties of the active SolidWorks document. To do this you would need to write your own add-in.
Another work around that just worked for me is to generate a BOM within a drawing and change directly the values by double-clicking left button on target cell -> keep link -> and finally introduce new value.
Are you talking about using the Property Tab Builder within SW or creating a new add-on similar to PTB
You can configure PTB to work with part, assemblies and drawing
I'm talking about creating a new add-on from PTB from which one can modify custom properties not only for individual parts, but for sub assemblies and assemblies too.
I doubt about an API function available for PTB
There are discussions and help files available to create macros to work within PropertyManager Tab
You can create any number of properties within PTB to work with all three types of SW files
See this discussion
As others have noted, the Property Tab Builder doesn't have an API so there is no way to harness it to accomplish what you want. An add-in is rather complicated to develop and administer so I would recommend sticking with a VBA macro if this is only for internal use. Here is code that will add a custom property to every component in an assembly:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swAssy As SldWorks.AssemblyDoc
Dim swComp As SldWorks.Component2
Dim swCompModel As SldWorks.ModelDoc2
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim i As Integer
Dim vComps As Variant
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swAssy = swModel
vComps = swAssy.GetComponents(False)
For i = 0 To UBound(vComps)
Set swComp = vComps(i)
Set swCompModel = swComp.GetModelDoc2
Set swCustPropMgr = swCompModel.Extension.CustomPropertyManager(Empty)
swCustPropMgr.Add2 "Description", swCustomInfoText, "test"
SolidWorks API Tutorials
have you tried the following:
Open the top level Assembly and have the Custom Properties Task Pane Tab pinned to your window.
If you click anywhere on the screen AWAY FROM ALL GEOMETRY, you will see that the Custom Properties tab will show you the properties of the current opened file.
Now simply click on a sub assembly in the tree structure. The Custom Properties tab will now show you the properties of the selected file.
This also works when you select any part within sub assemblies or parts within the top level assembly.
I hope this helps,
Retrieving data ...