Operation possible on parts, assemblies or drawings.

This operation allows you to access the ''Full value'' type options of the documents. For more information on the use of these parameters (see the API help).

The use of this operation is reserved for advanced users.

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

 

The number of the value is to be chosen from a list. This number must be numeric. It can be entered with the keyboard or by using the drop-down list:                 

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

 


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


- 1° We change the units of the system on ''.custom''.

The '' optionswUnitSystem'', in the list of ''Document Options (Integer)'', must be equal to the enumerator ''swUnitSystem_e'' which 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 list of ''Document Options (Integer)'', must be equal to the enumerator ''swLengthUnit_e'' which 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 list of ''Document Options (Integer)'', must be equal to the enumerator ''swUnitsMassPropMass_e'' which 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 make a macro record. Here for this same action we find the values explained above.


Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

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

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

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

End Sub


However, the values (where the enumerators are stored) are not found in the macro. To find the value contained in an enumerator, simply press F2 in the macro editor and the object explorer appears. By typing the name of the enumerator, for example "swUnitsMassPropMass  "In the search, the variables and their values are displayed.

 

Note 2:

With this method it is possible to control all the options of SOLIDWORKS

Check box (example ''Dressing/Always display the text with the same size'')

Integer (example change of unit as above)

Number with comma (example ''Annotation/Length of the attachment line'')

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


Note 3:

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

If the system units had not been set to ''.custom'', the change of unit of mass and length would have been without effect.


Note 4:

This allows the setting of document options only (tab ''Document properties'').

The system settings are not affected by batch processing.