I would like to know if it is possible, when closing a Solidworks 2015 file, to check (via VBA) the value of certain custom properties against the "system" values of Solidworks. And those on all configurations.
Indeed, I use "prop tab builder" but if values are changed and I don't update the properties, I close the file with erroneous custom properties.
For example, I would like to:
- the PP "Material" is verified with the Solidworks material data of each configuration.
- the "Unit Weight" PP is verified with the Solidworks mass data of each configuration.
- ditto for certain dimensions (linked to dimensions), volume, etc, etc, etc
This is the "Solidworks properties form editor" allowing you to set (on the left of the SW window) in a more ergonomic way than "File --> Properties... "
As for retrieving dimensions, it is possible to use sensors. To retrieve the value in VBA: http://help.solidworks.com/2015/english/api/sldworksapi/Get_and_Set_Sensor_Example_VB.htm
With ifs and Msgboxes it should be possible.
As for the material, it is imperative that the names are identical for it to work. It would be easier to use the SOLIDWORKS values directly. See if really necessary to copy the SW values into the PPs when closing (personally, I'll do it like that).
I created a macro assigned to the S key that zooms, rebuilds, puts in ISO view, gathers the tree, fills in properties and saves. Used instead of Ctrl+S, you are sure to always have your file up to date (rather than launching the macro when closing).
Hello, if you are talking about the "Ctrl+Q" type reconstruction, it only allows you to regenerate the construction tree and not to fill in the custom properties of the document or configurations.
That's why I need to find a way to check if the custom properties pointing to the SW System data are accurate.
These properties are then retrieved in PDM for post-processing, which is why I want a lock when closing the file in case of inconsistency.
Thank you for these clarifications. I have already made a macro (linked to a save button) to clean up the properties.
I have a large amount of files to process per day (and by several people) which is why a forgetting to launch the macro happens regularly (especially on the material because the form does not indicate that the data is modified and therefore if you don't press "Update" the SW material data is not filled in the Personal property "Material")
We have for each file document data common to all configs and data specific to each config.)
So I created a macro to copy the (common) properties of the document in all the configs (do we still have to launch the macro) and for the specific data we have to fill them in (via the properties form), which can also be forgotten...
That's why I want an alert when the file is closed.
For me the easiest way is to replace the "save" button with a macro that does these checks and then saves (I replaced the "print" button, to do checks, but you could also use the archived button if you use a safe).
Otherwise, I see that you have the myCADtools utilities, so you can do it in bulk on a whole folder with batchconverter or integration.
The properties are well related to the SW data (material, mass, volume, dimensions, etc...) and therefore updated (for some). My problem lies mainly in making it mandatory to fill in these properties and as a bonus to check the consistency (I have files that have for example the material filled in but the personal property is not up to date: I am looking for the cause). I have about 26 properties that must be filled in and with various and varied conditions. (e.g. if the material = "X", the property "color" must be filled in, etc...)
On the other hand, I can't find an answer on whether or not it is possible to launch a macro when closing the file