I made a macro to generate a PDF and a DWG of the open MEP in SW.
I take the opportunity to rename the generated file with name, number and hint.
For properties in the MEP, I use Revision = swModel.CustomInfo("Revision"), but what syntax should I use to retrieve a property from the PRT or ASM that is referenced in the MEP.
The macro allows me to generate the files individually, or to call it with the Integration utility to process a batch of files
I'm not sure you can do it directly from the MEP, but you can find the name of the referenced 3D model with the "GetReferencedModelName()" function, open this 3D model, note the properties you are interested in, close the 3D model and then continue your processing on the MEP, All this by macro of course.
Otherwise another proposal, I see that you have the Mycad tools, and Integration should allow you to perform all these functions without the need to create a macro.
I don't master macros enough to get started with d.roger's proposal.
With Integration, I haven't seen how to generate pdf or dwg. With Batch Converter, it works, and I can retrieve the information of the part!
But it's a bit cumbersome: I have to launch Integration and then Batch Converter, and each time drag the list of files (not possible to save a list of files for example) into each utility
Dim sModelName As String
Dim ValOut As String
Dim ResolvedValOut As String
Dim sConfigName As String
Dim WasResolved As Boolean
Dim swModelDocExt As ModelDocExtension
Dim swCustProp As CustomPropertyManager
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox ("Pas de document ouvert")
Else
If swModel.GetType <> 3 Then
MsgBox ("Il ne s'agît pas d'une mise en plan")
Else
Set swDraw = swModel
vSheetName = swDraw.GetSheetNames
vSheetNameArr = swDraw.GetSheetNames
For Each vSheetName In vSheetNameArr
bRet = swDraw.ActivateSheet(vSheetName): Debug.Assert bRet
Set swView = swDraw.GetFirstView 'Sélectionne le fond de plan
Set swView = swView.GetNextView 'Passe à la vue suivante pour exclure le fond de plan
'Debug.Print swView.GetName2
While Not swView Is Nothing
' Determine if this is a view of a part or assembly
sModelName = swView.GetReferencedModelName
sModelName = LCase(sModelName)
sConfigName = swView.ReferencedConfiguration
FileConnu = False
If InStr(sModelName, "sldprt") > 0 Then
nDocType = swDocPART
ElseIf InStr(sModelName, "slasm") > 0 Then
nDocType = swDocASSEMBLY
Else
nDocType = swDocNONE
Exit Sub
End If
If nDocType = 1 Or nDocType = 2 Then
Call Export
End If
Set swView = swView.GetNextView
Wend
Next vSheetName
End If
End If
End Sub
Sub Export()
Set swModel = swApp.OpenDoc6(sModelName, nDocType, swOpenDocOptions_Silent, "", nErrors, nWarnings)
Set swModelDocExt = swModel.Extension
Set swCustProp = swModelDocExt.CustomPropertyManager(sConfigName)
boolstatus = swCustProp.Get5("Revision", False, ValOut, ResolvedValOut, WasResolved)
End Sub
Following the boolstatus, you need to retrieve the ValOut or ResolvedValout value (depending on the field repatriated, the second corresponding to the value entered in the "Evaluated value" column) in a string variable and then concatenate it with the registration name.
I didn't put all the variables, you just have to add what you lack to your macro.
Does this loop count the different views of the drawing sheet or the drawing sheets? (Sheetname reminds me of the name of the sheet (like in Excel), but it would make sense to "count" the drawing views instead)