I am working on a macro that sets the overall drafting standard (loads external file) and deletes the current sheet format. I'm having some problems
with the sheet format delete right now. If I open an existing drawing and run the macro i get a popup callout saying "none of the selected enteties could be deleted."
However if I manually delete the sheet format on one sheet, the macro works on the other sheets in that drawing. Or if I delete the sheet format and load in a new one, the macro can delete the new sheet format.
Any soulutions to this? I'm currently selecting the sheet format in the feature manager tree and using EditDelete
---------------------------------
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModExt As SldWorks.ModelDocExtension
Dim swDraw As SldWorks.DrawingDoc
Dim boolstatus As Boolean
Dim bRetVal As Boolean
Dim value As Boolean
Dim instance As SldWorks.IModelDocExtension
Dim instance1 As SldWorks.ISheet
Dim swSheet As SldWorks.Sheet
Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc
Set swModel = swApp.ActiveDoc
Set swModExt = swModel.Extension
Set instance = swModel.Extension
'Set swSheet = swDraw.GetCurrentSheet
Set instance1 = swDraw.GetCurrentSheet
Dim valueFormat As String
valueFormat = instance1.GetSheetFormatName
'MsgBox valueFormat
If valueFormat <> "" Then
boolstatus = swModel.Extension.SelectByID2(valueFormat, "SHEET", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = swModel.Extension.SelectByID2(valueFormat, "SHEET", 0, 0, 0, False, 0, Nothing, 0)
'MsgBox valueFormat
'MsgBox boolstatus
swModel.EditDelete
End If
bRetVal = swModExt.LoadDraftingStandard("U:\Fredrik_std\hej1.sldstd")
value = instance.SetUserPreferenceToggle(swUserPreferenceToggle_e.swDetailingDualDimensions, swUserPreferenceOption_e.swDetailingDimension, True)
End Sub