Hi,
I'm attemping to put together a macro which iterates through each part configuration and then loops through the cut-list in a part file to look within each cut-list item for a variable called 'LENGTH'. If the variable exists, then it will add it to the 'Configuration Specific' properties list (or just print it to the debug console for the time being).
Here's my irrational code thus far:
<p>Sub main()</p><p> Dim swApp As SldWorks.SldWorks</p><p> Dim swModel As SldWorks.ModelDoc2</p><p> Dim swFeat As SldWorks.Feature</p><p> Dim swCustPropMgr As SldWorks.CustomPropertyManager</p><p> Dim swConfig As SldWorks.Configuration</p><p> Dim strValue As String</p><p> Dim vConfNameArr As Variant</p><p> Dim swConfigName As String</p><p> Dim i As Long</p><p> </p><p> Set swApp = Application.SldWorks</p><p> Set swModel = swApp.ActiveDoc</p><p> </p><p> Set swCustPropMgr = swModel.Extension.CustomPropertyManager(swConfigName)</p><p></p><p> vConfNameArr = swModel.GetConfigurationNames 'get full list of configurations</p><p> </p><p> For i = 0 To UBound(vConfNameArr) 'Do this for all configurations</p><p> </p><p> swConfigName = vConfNameArr(i)</p><p></p><p> Do While Not swFeat Is Nothing 'Do this for all cut-list items</p><p> </p><p> Set swCustPropMgr = swFeat.CustomPropertyManager</p><p> </p><p> <strong>If swCustPropMgr.Get4 = "LENGTH" Then</strong> 'if LENGTH exists then get value</p><p> </p><p> swCustPropMgr.Get4 "LENGTH", False, Empty, strValue</p><p> </p><p> Debug.Print (strValue) 'Print length valuen to console</p><p> </p><p> Exit Do</p><p> End If</p><p> Set swFeat = swFeat.GetNextFeature</p><p> Loop</p><p></p><p> Next i</p><p> </p><p>End Sub</p>
I'm thinking of a boolean instead of an if statement (at the point highlighted). I know it doesn't make much sense at the moment.
Can someone point me in the right direction?
Cheers,
Ray
SolidworksApi macros