AnsweredAssumed Answered

Error: Broken Link (inline GD&T) when inserting block using Macro

Question asked by Zhen Wei Tee on Jul 10, 2020
Latest reply on Jul 12, 2020 by Fifi Riri

When inserting a block using macro, the inline GD&T feature is broken 

 

The code are as follows: 

'==================== Preamble ===================='
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swBlockDef As SldWorks.SketchBlockDefinition

Dim swBlockInst As SldWorks.SketchBlockInstance

Dim nbrBlockInst As Integer

Dim vBlockInst As Variant

Dim MacroPath As String
Dim BlockPath As String

Dim NoteBlock As SketchBlockDefinition
Dim NoteBlockInst As SketchBlockInstance
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long


'=================================================='

'==================== MainCode ===================='
Sub main()

Set swApp = Application.SldWorks

'Get active document
Set swModel = swApp.ActiveDoc

'Display message and terminate if nothing is open
If swModel Is Nothing Then
MsgBox "Please open a file first.", vbOKOnly
End 'Terminate macro
End If

'Display message and terminate if not drawing
If Not swModel.GetType() = swDocDRAWING Then
MsgBox "Macro only work on drawing.", vbOKOnly
End
End If

MacroPath = swApp.GetCurrentMacroPathFolder
BlockPath = MacroPath & "\" & "Test.SLDBLK"
Debug.Print BlockPath
Set NoteBlock = swModel.SketchManager.MakeSketchBlockFromFile(Nothing, BlockPath, False, 0.5, 0)

Set swModel = Nothing

End Sub

'=================================================='

 

However, when inserting the same block manually, the GD&T feature show up correctly. 

 

What did i miss? Is there anyway to insert the block using macro without having the inline GD&T broken? 

Outcomes