Custom Properties Issue
Custom Properties Issue
(OP)
What should I do to make the custom properties "stick" to a SW file?
I have this issue since SW2007 SP2.2. I am using now SW2008 SP3.0
I use a VB6 macro to add the custom properties to assemblies and parts so they would show up in the BOM. For some unknown reason after I close the files their custom properties are sometimes deleted although I made sure they were properly saved. Sometimes they are saved. When I open the files next times their properties are not there and the drawing of the assembly shows just blank cells in the BOM.
I don't have this problem if I enter the properties manually in the custom properties window.
Did anyone experience something like this?
I have this issue since SW2007 SP2.2. I am using now SW2008 SP3.0
I use a VB6 macro to add the custom properties to assemblies and parts so they would show up in the BOM. For some unknown reason after I close the files their custom properties are sometimes deleted although I made sure they were properly saved. Sometimes they are saved. When I open the files next times their properties are not there and the drawing of the assembly shows just blank cells in the BOM.
I don't have this problem if I enter the properties manually in the custom properties window.
Did anyone experience something like this?






RE: Custom Properties Issue
Usually I hit a property change twice, once with add & once with change.
RE: Custom Properties Issue
1. Open the part
2. Run the macro
3. Enter the custom properties
4. Exit the macro
5. Save the part
6. Close the part
7. Open the assembly drawing
8. Check the BOM. It is updated
9. Save the drawing
10. Close the drawing
11. Open the part
12. Check the properties. They are gone. Not just blank or empty but gone completely as if they were never there.
Funny, eh!
RE: Custom Properties Issue
Are you reading the data?
e.g. Description = Part.CustomInfo("Description")
Are you deleting the data?
e.g. RetVal = Part.DeleteCustomInfo("Description")
Are you setting the data?
e.g. txtDescription.Text = Description
Are you then Adding the data?
e.g. RetVal = Part.AddCustomInfo("Description", "Text", UCase$(txtDescription.Text))
Bradley
SolidWorks Pro 2008 x64, SP4.0EV2
PDMWorks Workgroup, SolidWorks BOM,
Dell XPS Intel(R) Pentium(R) D CPU
3.00 GHz, 5 GB RAM, Virtual memory 10240 MB,
nVidia Quadro FX 3400
e-mail is Lotus Notes
RE: Custom Properties Issue
Heck, even your forms may be the issue. If you aren't closing our the form correctly, it could trigger your work not to be implemented.
One way to test how your macro is working is to msgbox's throughout the code to show you when a value for a custom property is set (real) and when it is not. Add label fields that allow you to see the evaluated value. Just ideas.
Here's a custom property macro that is working on 2007 (and presumably on 2008): http:
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
RE: Custom Properties Issue
-handleman, CSWP (The new, easy test)
RE: Custom Properties Issue
The properties are set, they show in the BOM. They just don't save with the file.
I am attaching the program to this post. Please take a look at it. It may not be the nicest program out there but I am pretty sure my process is correct.
RE: Custom Properties Issue
RE: Custom Properties Issue
It doesn't seem to do anything at all. I can put values in all the boxes, but Apply and Apply and Exit don't put any new custom properties into my file.
I can't really do any debug or anything because I don't have VB6.
Incidentally, any particular reason you used VB6 instead of a VBA macro? Just for curiosity's sake.
-handleman, CSWP (The new, easy test)
RE: Custom Properties Issue
I think I have a bug I never fixed and it gives errors with short file names. Rename your part something like 1111-11-11.
There is a data file I forgot to include in the zip file. Take it from here and put it in C:\
I started seven years ago as an exercise in VB6. I kept using it over the years and adding more features. It was covenient because I could easily modify it to adapt it to the standard of the company I was working for. I changed five work places since then.
I want to transfer it to VBA but never got time to do it. I also want to get rid of the forms and use the property manager window.
RE: Custom Properties Issue
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
RE: Custom Properties Issue
-handleman, CSWP (The new, easy test)
RE: Custom Properties Issue
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
RE: Custom Properties Issue
;)
RE: Custom Properties Issue
CODE
Dim dblDensity As Double, strMassProp As String, strTemp As String
' on selection of Apply or Exit & Save button delete existing custom properties
' and recreate with new values
If chkStore.Value = 1 Then Call cmdStore_Click
'Deleting all custom properties to keep files clean
'from part and assembly
retval = swCustPropMgrPP.Delete("Title")
retval = swCustPropMgr.Delete("Title")
retval = swCustPropMgr.Delete("Machine")
retval = swCustPropMgr.Delete("Description")
retval = swCustPropMgr.Delete("Description_1")
retval = swCustPropMgr.Delete("Vendor")
retval = swCustPropMgrPP.Delete("Weight")
retval = swCustPropMgr.Delete("Material")
retval = swCustPropMgr.Delete("Finish")
retval = swCustPropMgr.Delete("HeatTreatment")
retval = swCustPropMgr.Delete("Designby")
retval = swCustPropMgr.Delete("DesignDate")
retval = swCustPropMgr.Delete("Design")
retval = swCustPropMgr.Delete("Design_Date")
retval = swCustPropMgr.Delete("CatName")
retval = swCustPropMgr.Delete("Catno")
retval = swCustPropMgr.Delete("O'Hara_PartNumber")
'if $_Part_Type present delete it
retval = swCustPropMgr.Delete("$_Part_Type")
'from purchase part
retval = swCustPropMgrPP.Delete("Supplier_No")
retval = swCustPropMgrPP.Delete("VendorNo")
retval = swCustPropMgr.Delete("Supplier")
retval = swCustPropMgrPP.Delete("O'Hara_PartNumber")
Select Case sCatg
Case "PART"
'Adding new values to the part custom properties.
strTitle = UCase(txtTitle.Text)
retval = swCustPropMgr.Add2("Description", swCustomInfoText, strTitle)
retval = Part.SetMaterialPropertyName(sMatDB, UCase(cboMaterial.Text))
If Not retval Then retval = Part.SetMaterialPropertyName("solidworks materials.sldmat", UCase(cboMaterial.Text))
If Not retval Then retval = Part.SetMaterialPropertyName("ss solidworks materials.sldmat", UCase(cboMaterial.Text))
If retval Then
strTemp = Chr(34) & "SW-Material@" & doctitle & Chr(34)
Else
strTemp = UCase(cboMaterial.Text)
' retval = Part.RemoveMaterialProperty()
End If
retval = swCustPropMgr.Add2("Material", swCustomInfoText, strTemp)
retval = swCustPropMgr.Add2("Machine", swCustomInfoText, UCase(cboMachine.Text))
retval = swCustPropMgr.Add2("Finish", swCustomInfoText, UCase(cboFinish.Text))
retval = swCustPropMgr.Add2("Designby", swCustomInfoText, UCase(cboDesignBy.Text))
retval = swCustPropMgr.Add2("DesignDate", swCustomInfoText, UCase(txtDesignDate.Text))
retval = swCustPropMgr.Add2("O'Hara_PartNumber", swCustomInfoText, UCase(txtOHARAPN.Text))
'end of part processing
'start assembly
Case "ASSEMBLY"
'Adding new values to the part custom properties.
strTitle = UCase(txtTitle.Text)
retval = swCustPropMgr.Add2("Description", swCustomInfoText, strTitle)
retval = swCustPropMgr.Add2("Machine", swCustomInfoText, UCase(cboMachine.Text))
retval = swCustPropMgr.Add2("Material", swCustomInfoText, UCase(cboMaterial.Text))
retval = swCustPropMgr.Add2("Finish", swCustomInfoText, UCase(cboFinish.Text))
retval = swCustPropMgr.Add2("Designby", swCustomInfoText, UCase(cboDesignBy.Text))
retval = swCustPropMgr.Add2("DesignDate", swCustomInfoText, UCase(txtDesignDate.Text))
retval = swCustPropMgr.Add2("O'Hara_PartNumber", swCustomInfoText, UCase(txtOHARAPN.Text))
'end assembly processing
'start purchase part
Case "PURCHASE"
'Adding new values to the part custom properties.
retval = swCustPropMgr.Add2("$_Part_Type", swCustomInfoText, "P")
retval = swCustPropMgr.Add2("Supplier", swCustomInfoText, UCase(cboSupplier.Text))
retval = swCustPropMgr.Add2("Description", swCustomInfoText, UCase(txtPartName.Text))
retval = swCustPropMgrPP.Add2("VendorNo", swCustomInfoText, UCase(txtSuppPartNo.Text))
retval = swCustPropMgrPP.Add2("O'Hara_PartNumber", swCustomInfoText, UCase(txtOHARAPNPP.Text))
'add material if requested
If chkAddMat.Value = 1 Then
retval = Part.SetMaterialPropertyName(sMatDB, UCase(cboMatPP.Text))
If Not retval Then retval = Part.SetMaterialPropertyName("solidworks materials.sldmat", UCase(cboMatPP.Text))
If Not retval Then retval = Part.SetMaterialPropertyName("ss solidworks materials.sldmat", UCase(cboMatPP.Text))
If retval Then
strTemp = Chr(34) & "SW-Material@" & doctitle & Chr(34)
Else
strTemp = UCase(cboMatPP.Text)
' retval = Part.RemoveMaterialProperty()
End If
retval = swCustPropMgr.Add2("Material", swCustomInfoText, strTemp)
End If
Set Config = Part.GetActiveConfiguration()
Config.AlternateName = UCase(txtSuppPartNo.Text) ' make " " for blank in part no.
Config.UseAlternateNameInBOM = True
'end processing purchase part
End Select
retval = Part.EditRebuild3
End Sub
RE: Custom Properties Issue
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group