AnsweredAssumed Answered

Change precision in flatpattern view

Question asked by Niels Raahauge on Sep 21, 2018
Latest reply on Sep 21, 2018 by Niels Raahauge

use of value = instance.SetPrecision2(Primary, Dual, PrimaryTol, DualTol) when swDispDim = swSubFeat.GetNextDisplayDimension(swDispDim)

 

I want to change all dimension precisions on the flat pattern view..

something wrong with the instance - I think I am not familiar with the use of the objects.  Can somebody help?

 

 

'-----------------------------------------------------------------------------------------

'open a drawing with a flatpattern view: DefaultSM-FLAT-PATTERN
'Macro find the view name with the flatpattern
'Scan all dimensions
'I want to change precision on all the dimensions in the view
'value = swDispDim.SetPrecision2(1, 1, 1, 1)

Option Explicit

Sub main()
    Dim swApp                   As SldWorks.SldWorks
    Dim swModel                 As SldWorks.ModelDoc2
    Dim swFeat                  As SldWorks.Feature
    Dim swSubFeat               As SldWorks.Feature
    Dim swDispDim               As SldWorks.DisplayDimension
    Dim swDim                   As SldWorks.Dimension
    Dim swAnn                   As SldWorks.Annotation
    Dim bRet                    As Boolean
    Dim swDraw As SldWorks.DrawingDoc
    Dim swView As SldWorks.View
    Dim FlatPatternView As String
   
    Dim instance As IDisplayDimension
    Dim value As Integer
   
    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc
    Set swFeat = swModel.FirstFeature
    Set swDraw = swModel

'---find flat pattern view
   Set swView = swDraw.GetFirstView
    ' Get first drawing view in first sheet
    Set swView = swView.GetNextView
    Do While Not swView Is Nothing
        If swView.ReferencedConfiguration = "DefaultSM-FLAT-PATTERN" Then
        Debug.Print "Flat patternview:  " & swView.Name
        FlatPatternView = swView.Name
        End If
        Set swView = swView.GetNextView
    Loop
'---

    Do While Not swFeat Is Nothing
   
        Set swSubFeat = swFeat.GetFirstSubFeature
        Do While Not swSubFeat Is Nothing

If swSubFeat.Name = FlatPatternView Then

            Set swDispDim = swSubFeat.GetFirstDisplayDimension

            Do While Not swDispDim Is Nothing
                Set swAnn = swDispDim.GetAnnotation
                Set swDim = swDispDim.GetDimension
                Debug.Print "          [" & swDim.FullName & "] = " & swDim.GetSystemValue2("")
                ' FAULT presisition are not set ?
                 value = swDispDim.SetPrecision2(1, 1, 1, 1)
                'value = instance.SetPrecision2(Primary, Dual, PrimaryTol, DualTol)
                 Set swDispDim = swSubFeat.GetNextDisplayDimension(swDispDim)
            Loop
End
End If
            Set swSubFeat = swSubFeat.GetNextSubFeature
        Loop
       
        Set swDispDim = swFeat.GetFirstDisplayDimension
        Do While Not swDispDim Is Nothing

            Set swAnn = swDispDim.GetAnnotation
            Set swDim = swDispDim.GetDimension
            Debug.Print "    [" & swDim.FullName & "] = " & swDim.GetSystemValue2("")
            Set swDispDim = swFeat.GetNextDisplayDimension(swDispDim)
instance = swDim

        Loop
       
        Set swFeat = swFeat.GetNextFeature

    Loop

End Sub

Outcomes