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.SketchBlockDefinitionDim swBlockInst As SldWorks.SketchBlockInstance
Dim nbrBlockInst As Integer
Dim vBlockInst As Variant
Dim MacroPath As String
Dim BlockPath As StringDim 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 IfMacroPath = 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?
Edit/Update:
Both method (macro/manual insert) is done on entirely new drawing