Po kilku badaniach i próbach, oto co skompilowałem:
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim Filepath As String
Dim fileName As String
Dim Revision As String
Dim exportData As SldWorks.ExportPdfData
Dim lErrors As Long
Dim lWarnings As Long
Dim confName As String
Dim revNmb As String
Dim val As String
Dim resolved As Boolean
Dim swview As SldWorks.View
Dim swRefModel As ModelDoc2
Dim swRefAssy As AssemblyDoc
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim ValOut As String
Dim numéro As String
Dim description As String
Sub Main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox "Tu as pensé à ouvrir ta mise en plan?", vbCritical
End
End If
If swModel.GetType <> swDocDRAWING Then
MsgBox "Et si tu ouvrais ta mise en plan avant?", vbCritical
End
End If
Set swDraw = swModel
If swDraw.GetPathName = "" Then
swDraw.Save
End If
If swModel.GetType = swDocDRAWING Then ' Pour savoir si le document est un plan
Set swDraw = swApp.ActiveDoc
Set swview = swDraw.GetFirstView 'selectionne le fond de plan
Set swview = swview.GetNextView 'selectionne la premier vue
Set swRefModel = swview.ReferencedDocument
Set swCustPropMgr = swRefModel.Extension.CustomPropertyManager("")
swCustPropMgr.Get4 "Ville", True, ValOut, "Ville", False 'récupère la valeur de la propriété "Ville"
swCustPropMgr.Get5 "Rue/Quartier", True, ValOut, "Rue/Quartier", False 'récupère la valeur de la propriété "Rue/Quartier"
swCustPropMgr.Get2 "indice", True, ValOut, "indice", False 'récupère la valeur de la propriété "indice"
Dim dateNow As String
dateNow = Replace(Date, "/", ".")
Filepath = "D:\Téléchargements\Plan PDF"
Filepath = Filepath + "\"
fileName = ValOut & " " & "-" & " " & ValOut & " " & "-" & " " & "Ind." & " " & ValOut & " " & "-" & " " & dateNow
swDraw.SaveAs (Filepath + fileName + ".PDF")
Exit Sub
End If
End Sub
Pozwólcie, że wyrażę się jasno, zrozumiałem tylko niewielką część tego wszystkiego, ale jest to funkcjonalne, z wyjątkiem części.
Przejrzałem kilka tematów związanych z odzyskiwaniem nieruchomości, ale nie rozumiem, jak to działa:
swCustPropMgr.Get4 "Ville", True, ValOut, "Ville", False 'récupère la valeur de la propriété "Ville"
swCustPropMgr.Get5 "Rue/Quartier", True, ValOut, "Rue/Quartier", False 'récupère la valeur de la propriété "Rue/Quartier"
swCustPropMgr.Get2 "indice", True, ValOut, "indice", False 'récupère la valeur de la propriété "indice"
Get4 lub Get5... Nie wiem, jak powiedzieć:
Wartość przypisana do "Miasto" to wartość znajdująca się w następnym polu
A potem, aby móc to przepisać w nazwie, ponieważ na razie oprócz daty nie wyświetlają się nazwy właściwości. Oto wynik, który otrzymuję: " - - Ind. - 04.02.2019.PDF"
Ponadto, aby zrozumieć trochę więcej, jaki jest cel wszystkich wierszy poniżej "Opcja jawna" stylu:
Dim swApp As SldWorks.SldWorks
Z góry dziękuję