Check prop. Compared to system values when closing

Hello

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

In the event of an error, alert before closing.

 

Thank you for your help

 

 

 

What is "prop tab builder"?

A utility?

Hello

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... "

 Cdt

Hello

Instead of trying to check each value or dimensions that will change depending on the files.

Why not force rebuild before saving?

2 Likes

Hello

To retrieve the custom properties of a part, the commands are as follows:

'Retrieve Name Properties
ListProp = Part.GetCustomInfoNames2("")

'Reading the value of a property:
ValProp = Part.GetCustomInfoValue("", "Nom_Propriété")

To retrieve the material name from the solidworks properties:

http://help.solidworks.com/2015/english/api/sldworksapi/get_material_example_vb.htm

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.

Cdt

 

Hello

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.

Cdt

Why not put automatic functions in properties? Normally it follows on its own afterwards

 

For the material: "SW-Material@Pièce1.SLDPRT"

For the weight: "SW-Mass@Pièce1.SLDPRT"

 

If the room is called "Room1" of course. Otherwise, we have to adapt. But you'll find them in the drop-down  menu anyway


sans_titre.png

Hello

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.

 

Hello and thank you,

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

Vincent

1 Like

No solution except for specific development.