Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reload custom properties?

Status
Not open for further replies.

LFowler

Mechanical
Feb 7, 2012
7
I threw together a macro to delete custom properties from a drawing which I put below. My problem is that although the macro works, the 'Custom Properties' tab on the side does not update automatically.

I've taken a look at other macros similar to mine in fuctionality, but none actually solve this issue. Is there a solution for this problem?

Code:
Sub main()

Dim swApp       As SldWorks.SldWorks
Dim swModel     As SldWorks.ModelDoc2
Dim vPropNames  As Variant
Dim bool        As Integer
Dim i           As Integer
Dim j           As Integer
Dim PartNoName  As String
Dim AddProp     As Boolean

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

vPropNames = swModel.GetCustomInfoNames()
j = 0

For i = 0 To UBound(vPropNames)
    If Not vPropNames(i) = "UNIT_OF_MEASURE" Then
        bool = swModel.DeleteCustomInfo(vPropNames(i))
        j = j + 1
        If bool = 0 Then
            MsgBox "Error deleting '" & vPropNames(i) & "' property."
            j = j - 1
        End If
    End If
Next i

PartNoName = "$PRP:" & """SW-File Name"""
AddProp = swModel.AddCustomInfo("PartNo", "Text", PartNoName)

If j > 1 Then
    MsgBox j - 1 & " properties deleted."
End If

bool = swModel.ForceRebuild3(False)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor