Dim strTemplatePath As String strTemplatePath = swApp.GetUserPreferenceStringValue _ (swUserPreferenceStringValue_e.swDefaultTemplateDrawing) Set swModel = swApp.NewDocument(strTemplatePath, _ swDwgPapersUserDefined, 0.2794, 0.2159) Set swDraw = swModel swDraw.SetupSheet5 "Sheet1", 12, 12, 1, 4, False, _ strFormatPath, 0.2794, 0.2159, "Default", True Dim swSheet As SldWorks.Sheet Dim vSheetNames As Variant Dim i As Integer vSheetNames = swDraw.GetSheetNames For i = 0 To UBound(vSheetNames) Set swSheet = swDraw.Sheet(vSheetNames(i)) If i = 0 Then swSheet.SetName "Full Assy" If i = 1 Then swSheet.SetName "Handle" Next i Dim vViews As Variant vViews = swSheet.GetViews For i = 0 To UBound(vViews) Set swView = vViews(i) swView.SetDisplayTangentEdges2 swTangentEdgesHidden Next i swDraw.InsertModelAnnotations3 swImportModelItemsFromEntireModel, _ swInsertDimensionsMarkedForDrawing, True, True, False, True Dim swDispDim As SldWorks.DisplayDimension swModel.ClearSelection2 True For i = 0 To UBound(vViews) Set swView = vViews(i) Set swDispDim = swView.GetFirstDisplayDimension5 While Not swDispDim Is Nothing swModel.Extension.SelectByID2 swDispDim.GetNameForSelection, _ "DIMENSION", 0, 0, 0, True, 0, Nothing, 0 Set swDispDim = swDispDim.GetNext5 Wend Next i swModel.Extension.AlignDimensions swAlignDimensionType_AutoArrange, 0.06 Dim swFeat As SldWorks.Feature Set swFeat = swDraw.FeatureByName(swView.Name) swFeat.Select2 False, 0 Dim vNotes As Variant vNotes = swDraw.AutoBalloon4(swDetailingBalloonLayout_Right, _ True, swBS_Circular, 2, 1, Empty, 1, Empty, "-None-", True) 'Add BOM to first sheet Dim swBOMAnn As SldWorks.BomTableAnnotation Set swBOMAnn = swIsoView.InsertBomTable3 _ (False, 0.27, 0.20808, swBOMConfigurationAnchor_TopRight, _ swBomType_PartsOnly, "Default", strBOMTemplatePath, False) 'Change BOM column to reference Part No custom property swBOMAnn.SetColumnCustomProperty 2, "PartNo" 'Change BOM column name and column widths Dim swTableAnn As SldWorks.TableAnnotation Set swTableAnn = swBOMAnn swTableAnn.Text(0, 2) = "PART NO" swTableAnn.SetColumnWidth 1, 0.04, swTableRowColChange_TableSizeCanChange swTableAnn.SetColumnWidth 2, 0.03, swTableRowColChange_TableSizeCanChange 'Save drawing to the same location as model Dim strFilePath As String strFilePath = swIsoView.GetReferencedModelName strFilePath = Replace(strFilePath, "SLDASM", "SLDDRW") swModel.Extension.SaveAs strFilePath, 0, 0, Nothing, Empty, Empty