Operation possible on parts, assemblies or drawings.

This operation gives access to the "Entire value" options of the documents. For more information on how to use these parameters (see API help).

This operation is for advanced users only.

The choice is made from a list of options corresponding to the enumerator ''.swUserPreferenceIntegerValue_e'' :

 

The value number is selected from a list. This number must be numeric. It can be entered using the keyboard or the drop-down list:                 

Version 6 corresponds to swDxfFormat_R2010, (see swDxfFormat_e Enumeration API help).

 


Example : How to change SOLIDWORKS document unit options to length=mm and mass=Kg?


- 1° Change the system units to ''.custom''.

The '' optionswUnitSystem'', in the ''Document options (Integer)'' list, must be equal to the '' enumerator.swUnitSystem_ewhich contains :

swUnitSystem_CGS = 1

swUnitSystem_MKS = 2

swUnitSystem_IPS = 3

                                       swUnitSystem_Custom = 4

swUnitSystem_MMGS = 5


- 2° We change the units of length on ''.mm''.

The '' optionswUnitsMassPropLength'', in the ''Document options (Integer)'' list, must be equal to the '' enumerator.swLengthUnit_ewhich contains :


swMM = 0

swCM = 1

swMETER = 2

swINCHES = 3

swFEET = 4

swFEETINCHES = 5

swANGSTROM = 6

swNANOMETER = 7

swMICRON = 8

swMIL = 9

swUIN = 10


- 3° We change the mass units on ''.kg''.

The '' optionswUnitsMassPropMass'', in the ''Document options (Integer)'' list, must be equal to the '' enumerator.swUnitsMassPropMass_ewhich contains :


swUnitsMassPropMass_Milligrams = 1

swUnitsMassPropMass_Grams = 2

                                       swUnitsMassPropMass_Kilograms = 3

swUnitsMassPropMass_Pounds = 4


Note 1:

To find these enumerators and their values, the easiest way is to record a macro. Here, for the same action, we find the values explained above.


Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitSystem0, swUnitSystem_e.swUnitSystem_Custom)

boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropLength0, swLengthUnit_e.swMM)

boolstatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitsMassPropMass0, swUnitsMassPropMass_e.swUnitsMassPropMass_Grams)

End Sub


However, the macro does not contain the values (where the enumerators are stored). To find the value contained in an enumerator, simply press F2 in the macro editor, and the object explorer appears. By typing the enumerator's name, for example "swUnitsMassPropMass When you click on "Search", the variables and their values are displayed.

 

Note 2:

This method can be used to control all the SOLIDWORKS options

Check box (e.g. ''Dressing/always display text at the same size'')

Integer (e.g. change of unit as above)

Number with decimal point (example ''Annotation/Tie line length'')

Text (example ''Annotation/References/Next label'')


Note 3:

Some options are linked to each other, as in the example above.

If the system's units had not been set to '', it would have been impossible to use the system.customThe change of unit of mass and length would have had no effect.


Note 4:

This allows you to set document options only ("Document properties" tab).

System options are not affected by batch processing.