Alin Vargatu did a presentation about this at world but i think advance select only drops down one level. If you can find him on here and shoot him a message i'm sure he would be the best to ask
Thanks for the reply.
Advanced select does seem to work all the way through the subassemblies. The issue is that custom properties only lets you select one file type at a time.
I believe that what I need requires a macro, but I am not sure how to do it.
Thanks for the help! I wasn't able to find a single post that answers my question; that's why I started this thread. I am very new to VBA and using macros with SolidWorks, so it is difficult to troubleshoot any issues that come up.
I will keep trying. I should be able to combine this post about how to write to a property (https://forum.solidworks.com/message/128301#128301) with a post about how to get a specific property value (https://forum.solidworks.com/message/366446#366446) and a post that works within an assembly to write a custom property to all the subcomponents (https://forum.solidworks.com/message/255198).
I will update this thread on how it goes. Thanks again.
The macro is working now.
It does these 3 things:
- Add assembly quantity property to each component
- Add stock description property to each component
- Copy the project title entered at the top level assembly to each component
#3 is the one I was adding via this thread. Thanks again for the help!
FYI I referenced 3 posts:
- This post about how to write to a property (https://forum.solidworks.com/message/128301#128301)
- This post about how to get a specific property value (https://forum.solidworks.com/message/366446#366446)
- This post that works within an assembly to write a custom property to all the subcomponents (https://forum.solidworks.com/message/255198)
''Originally an equation built by Josh Brady of the Solidworks Forums
''WILL AUTO SUM THE QUANTITY OF UNIQUE PARTS IN ALL ASSEMBLIES WHEN RAN FROM THE TOP ASSEMBLY.
''CURRENTLY NEED TO MANUALLY ADD CUSTOM PROPERY 'Cfg4Qty'-'Text'-'Default' TO TOP LEVEL ASSEMBLY BEFORE RUNNING
Dim swApp As SldWorks.SldWorks 'added this line
Dim Assembly As ModelDoc2 'added this line
Dim myAsy As AssemblyDoc
Dim Cfg As String
Dim CmpDoc As ModelDoc2
Dim i As Long
Dim j As Long
Dim cCnt As Long
Dim NoUp As Long
Dim myCmp As Component2
Dim tCmp As Component2
Dim ProjTitle As String 'The variable for storing the assembly Project Title
Dim tm As Double
tm = Timer
Set swApp = Application.SldWorks 'added this line
Set Assembly = swApp.ActiveDoc 'added this line
Set myAsy = Assembly
If Assembly.ConfigurationManager.ActiveConfiguration.name <> Assembly.CustomInfo2("", "Cfg4Qty") Then
Assembly.Extension.ShowSmartMessage "Qtys not updated due to config", 1000, True, True
ProjTitle = myAsy.CustomInfo2(Cfg, "ProjectTitle") 'Read the project title from the assembly
NoUp = 0
myCmps = myAsy.GetComponents(False)
For i = 0 To UBound(myCmps)
Set myCmp = myCmps(i)
If (myCmp.GetSuppression = 3) Or (myCmp.GetSuppression = 2) Then
cCnt = 0
Set CmpDoc = myCmp.GetModelDoc
Cfg = myCmp.ReferencedConfiguration
For j = 0 To UBound(myCmps)
Set tCmp = myCmps(j)
If tCmp.GetSuppression <> 0 Then
If tCmp.GetModelDoc2 Is CmpDoc Then
If tCmp.ReferencedConfiguration = Cfg Then
cCnt = cCnt + 1
CmpDoc.AddCustomInfo3 Cfg, "AutoQty", 30, ""
CmpDoc.AddCustomInfo3 Cfg, "QtyIn", 30, ""
CmpDoc.CustomInfo2(Cfg, "AutoQty") = cCnt
CmpDoc.CustomInfo2(Cfg, "QtyIn") = Assembly.GetTitle & " Cfg " & Assembly.ConfigurationManager.ActiveConfiguration.name
''Added Stock Description Custom Property to be used in BOM
CmpDoc.AddCustomInfo3 Cfg, "StockDescription", 30, ""
CmpDoc.CustomInfo2(Cfg, "StockDescription") = "$PRP:" & Chr(34) & "HasDiameter" & Chr(34) & "$PRP:" & Chr(34) & "StockThickness" & Chr(34) & "$PRP:" & Chr(34) & "HasWidth" & Chr(34) & "$PRP:" & Chr(34) & "StockWidth" & Chr(34) & "$PRP:" & Chr(34) & "HasWall" & Chr(34) & "$PRP:" & Chr(34) & "StockWall" & Chr(34) & " x $PRP:" & Chr(34) & "StockLength" & Chr(34) & " LG"
''Added Project Title Custom Property as read from assembly
CmpDoc.AddCustomInfo3 Cfg, "ProjectTitle", 30, ""
CmpDoc.CustomInfo2(Cfg, "ProjectTitle") = ProjTitle
NoUp = NoUp + 1
Assembly.Extension.ShowSmartMessage NoUp & " Parts not updated due to lightweight (" & Timer - tm & "s)", 10000, True, True