I thought I would share a few code snippets relating to the reading and saving of SW custom properties using the API.
This is not something you can easily do a macro "recording" of.. as it is handled through a pop up window so it is not really captured in the recorded macro.
'To set up the environment.. you need to connect to the Part object and get the configuration name.
Set swapp = CreateObject("SldWorks.Application")
Set Part = swapp.ActiveDoc
sConfigName = Part.GetActiveConfiguration.Name
'Leave the sConfigName variable blank if you was to set the properties just of the part and not config specific
‘To read custom property info
txtDocNumber.Text = Part.GetCustomInfoValue(sConfigName, "PW_Number")
txtDesc1.Text = Part.GetCustomInfoValue(sConfigName, "PW_Description1")
'Deleting Custom Properties retval = Part.DeleteCustomInfo2(sConfigName, "PW_Number") retval = Part.DeleteCustomInfo2(sConfigName, "PW_Description1")
'Adding custom properties and summary info retval = Part.AddCustomInfo3(sConfigName, "PW_Number", swCustomInfoText, UCase(txtDocNumber.Text)) retval = Part.AddCustomInfo3(sConfigName, "PW_Description1", swCustomInfoText, UCase(txtDesc1.Text))
Part.SummaryInfo(swSumInfoTitle) = txtDocNumber.Text
You might need to add in some API constants as well.. Public Enum swCustomInfoType_e swCustomInfoUnknown = 0 swCustomInfoText = 30 ' VT_LPSTR swCustomInfoDate = 64 ' VT_FILETIME swCustomInfoNumber = 3 ' VT_I4 swCustomInfoYesOrNo = 11 ' VT_BOOL End Enum Hope this gets you started.
By Scott Evans - InFlow Technologies - www.inflow-tech.com