Hello For a drawing export only with views, I'm looking for a macro that: 1 - hides the basemap (uncheck ' Show basemap ' in sheet property) 2-hides the table ‹ Nomenclature1 › 3-Hide Table ‹ Revision Table1 › then a .ai registration and finally redisplay the hide elements.
Dim swSheet As SldWorks.Sheet
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As ModelDocExtension
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swAnn As SldWorks.Annotation
Dim boolstatus As Boolean
Dim sPathName As String
Dim lErrors As Long
Dim lWarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox ("Pas de document ouvert")
Exit Sub
Else
Set swModelDocExt = swModel.Extension
If swModel.GetType <> 3 Then
MsgBox ("Il ne s'agît pas d'une mise en plan")
Else
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
swSheet.SheetFormatVisible = False ' Masque le fond de plan
Set swView = swDraw.GetFirstView
Do While Not Nothing Is swView
Set swAnn = swView.GetFirstAnnotation3
Do While Not Nothing Is swAnn
If swAnn.GetType = swTableAnnotation Then 'Verifie si c'est un objet de type table (BOM ou révision)
swAnn.Visible = swAnnotationHidden ' Cache les tables
End If
Set swAnn = swAnn.GetNext3
Loop
Set swView = swView.GetNextView
Loop
sPathName = swModel.GetPathName 'Recupere le nom complet du document actif
sPathName = Left(sPathName, Len(sPathName) - 6) 'Suppression de l'extension
sPathName = sPathName + "ai" 'Formatage du nom d'enregistrement
boolstatus = swModelDocExt.SaveAs3(sPathName, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, Nothing, lErrors, lWarnings)
End If
swSheet.SheetFormatVisible = True 'Affiche le fond de plan
Set swView = swDraw.GetFirstView
Do While Not Nothing Is swView
Set swAnn = swView.GetFirstAnnotation3
Do While Not Nothing Is swAnn
If swAnn.GetType = swTableAnnotation Then 'Verifie si c'est un objet de type table (BOM ou révision)
swAnn.Visible = swAnnotationVisible ' Affiche les tables
End If
Set swAnn = swAnn.GetNext3
Loop
Set swView = swView.GetNextView
Loop
End If
End Sub
Didn't handle whether the ai file exists or not (possible to add)