AnsweredAssumed Answered

Macro is changing the chamfer angular precision

Question asked by Barbara Jerin on Apr 9, 2019
Latest reply on Apr 24, 2019 by Barbara Jerin

Hey guys,


I need some help figuring out why my macro is changing the angular precison of the chamer from None to double decimal. I use the macro to change the mass to kg and to define the number of decimal places based on the weight. But somehow the macro also affects the angular precision of the chamfers. For example it changes it from 10x45° to 10x45,00°.

The section of the code that makes this happen:


Option Explicit

Dim swApp               As SldWorks.SldWorks

Dim swModel             As SldWorks.ModelDoc2

Dim swCustPropMgr       As SldWorks.CustomPropertyManager

Dim vCustPropNames      As Variant

Dim vCustPropVals       As Variant

Dim Current             As New Collection

Dim Final               As New Collection

Dim i                   As Integer

Dim blnFound            As Boolean

' Decimal places:

Dim Val2 As Integer

Dim swModExt            As ModelDocExtension

Dim MassProp            As MassProperty

Dim boolstatus          As Boolean

' Apply sort by rules for BOMs

Dim swDraw          As SldWorks.DrawingDoc

Dim swView          As SldWorks.View

Dim swTable         As SldWorks.ITableAnnotation

Dim swSpecTable     As BomTableAnnotation

Dim vTable          As Variant

Dim j               As Integer

Dim swSortData      As BomTableSortData

Dim status          As Boolean

' Rebuild

Dim boolstatusRebuild As Boolean

' Save file

Dim boolstatusSave As Boolean

Dim swErrors As Long

Dim swWarnings As Long


'--------------------------------------Mass Units to KG--------------------------------------


    swModel.Extension.SetUserPreferenceInteger swUserPreferenceIntegerValue_e.swUnitSystem, swUserPreferenceOption_e.swDetailingNoOptionSpecified, swUnitSystem_Custom

    swModel.Extension.SetUserPreferenceInteger swUserPreferenceIntegerValue_e.swUnitsMassPropMass, swUserPreferenceOption_e.swDetailingNoOptionSpecified, swUnitsMassPropMass_Kilograms


'--------------------------------------Set number of decimal places--------------------------------------


    Set MassProp = swModel.Extension.CreateMassProperty

    Val2 = 0  ' no decimal

    If (MassProp.Mass < 1000) Then Val2 = 1 ' one decimal

    If (MassProp.Mass < 100) Then Val2 = 2  ' two decimals

    If (MassProp.Mass < 10) Then Val2 = 3   ' three decimals

    boolstatus = swModel.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swUnitsMassPropDecimalPlaces, Val2)


End Sub


There are some other things that the macro performs, but have no effect on the angular precision.