Kevin Chandler

[Updated v3] Macro utility: Notify on part save when no material is specified

Discussion created by Kevin Chandler on Jan 15, 2020
Latest reply on Jan 28, 2020 by Kevin Chandler

Update 01/28/2020: Per Josh Brady's kind assistance, #2 has been improved and is attached as #3.


Update 01/27/2020: Added "NotifyNoMaterialOnSave2.swp" which reads the part's material directly.

No need to modify the macro unless you want to display a different message in the dialog.

If so, edit the string in: NoMaterialMessage = "Material is not specified!"

The original macro is still attached, so the OP below applies mostly to it.




This macro, once started, will display a dialog whenever a part is saved without a material being specified:


It does this by traversing the features and material, whether it's shown in the tree or not, is always before the Front plane.

The macro finds the Front plane and examines the feature name prior to it.

If this feature's test matches the no material text, then the no material dialog displays.

The part is saved regardless.

Assemblies and drawings aren't applicable and this macro doesn't check for parts edited within an assembly.


To change the displayed message, edit the macro and edit the quoted content of NoMaterialMessage.

To change to another language (if SW doesn't use English internally for these), edit the macro and edit the quoted content of NoMaterialName and FrontPlaneName as these must match literally.

(My home SW is "Front Plane", but my work SW is "Front", so when I got in add this to the forum, this macro didn't work until the edit.)


If you're not sure about the material or first plane's name, add this Msgbox line and run this macro on a part with one feature.

The Msgbox displays for each feature, so the more features there are, the more times you must click OK.

Remove this Msgbox line when you've got the correct text strings.


When started, this dialog displays:

If you don't want to show this dialog, edit the macro and comment out (or delete) this line in main():


I hope you find this useful.

Comments and feedback are most welcome.