Divide the Multi-Sheet Assembly and Parts Plan

Hello

As part of a historical plan rework created in Windows folders, and transferred to the pdm for a few years, I would like to know if any of you would have a trick or a macro in order to "explode" to divide multi-sheet drawings

historically the BE edit a drawing in which we had the assembly and then at each sheet the detailed plans of the parts included in this assembly.

The methodology having evolved following the passage via PDM and automated tasks, then the change of supplier then the change of subcontractor etc .... Today, when we "copy" an old assembly, we have these famous multi-sheet plans that do not correspond to the current process.

Have any of you already been confronted with the problem and have found a solution other than to recreate each room plan by removing the sheets in the so-called general plan as you go?

Currently we use smartdrawing to generate the basemaps of each room, then we copy the sheets of the multi sheet into each file generate, archive and then process the basemaps via integrations.

inappropriate = > human operations that sometimes mix up the drawings

 

Hello

See attached example to separate a multi-sheet MEP into multiple sheets.

https://www.javelin-tech.com/blog/2014/03/save-multi-sheet-as-its-own-drawing-or-combine-multiple-drawings/

It is undoubtedly possible to automate this via macro if you have some knowledge of VBA.

For the macro you also need to know how you name each MEP from each leaf. (name of the sheet?)

And with a bit of luck it will be enough to get a macro and modify it slightly to rename your MEPs as you wish.

 

Edit: here is another link forgotten in the previous one for macro example (but not found the macro that goes with it)

https://www.youtube.com/watch?v=lkU1acf2PNg

 

1 Like

Thank you for the feedback, 

The YouTube video is what I'm looking for

How do I download the "Save Drawing Sheet File.swp" macro!!  

I look for it if I find it I post it

 

After some research not found, but if anyone has time to devote to it the solution would be to copy one of the sheets of the multi-sheet, then paste it into a new sheet and save it with the name of this sheet.

 

Otherwise I had this macro modify from a macro for pdf export but it exports all the sheets (not just the one you want) and you would have to add the deletion of all the unwanted sheets.

'Description: Macro to export Drawing Sheets As PDF with sheet name as file name.

'Precondition: Any active drawing file

'Postconditions: PDF file in the same location as drawing file.


' Please back up your data before use and USE AT OWN RISK

' This macro is provided as is.  No claims, support, refund, safety net, or
' warranties are expressed or implied.  By using this macro and/or its code in
' any way whatsoever, the user and any entities which the user represents,
' agree to hold the authors free of any and all liability.  Free distribution
' and use of this code in other free works is welcome.  If any portion of
' this code is used in other works, credit to the authors must be placed in
' that work within a user viewable location (e.g., macro header).  All other
' forms of distribution (i.e., not free, fee for delivery, etc) are prohibited
' without the expressed written consent by the authors.  Use at your own risk!
' ------------------------------------------------------------------------------
' Written by: Deepak Gupta (http://gupta9665.wordpress.com/)
' -----------------------------------------------------------------------------

Sub main()

Dim swApp                   As SldWorks.SldWorks
Dim swModel                 As SldWorks.ModelDoc2
Dim swDraw                  As SldWorks.DrawingDoc
Dim swSheet                 As SldWorks.Sheet
Dim vSheetNameArr           As Variant
Dim vSheetName              As Variant
Dim bRet                    As Boolean
Dim swExportPDFData         As SldWorks.ExportPdfData
Dim lErrors                 As Long
Dim lWarnings               As Long

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

' Is document active?

If swModel Is Nothing Then

    swApp.SendMsgToUser2 "A Drawing document must be active.", swMbWarning, swMbOk

    Exit Sub

End If
 

' Is it a Drawing document?

If swModel.GetType <> swDocDRAWING Then

    swApp.SendMsgToUser2 "A Drawing document must be active.", swMbWarning, swMbOk

    Exit Sub

End If


Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet

vSheetNameArr = swDraw.GetSheetNames
For Each vSheetName In vSheetNameArr

bRet = swDraw.ActivateSheet(vSheetName): Debug.Assert bRet

swDraw.ViewZoomtofit2

Set swExportPDFData = swApp.GetExportFileData(1)
swExportPDFData.SetSheets swExportData_ExportSpecifiedSheets, Nothing
'swModel.Extension.SaveAs vSheetName + ".pdf", 0, 0, swExportPDFData, lErrors, lWarnings
swModel.Extension.SaveAs Path & "\" & vSheetName & ".slddrw", 0, 0, Nothing, lErrors, lWarnings
Next vSheetName

End Sub

 

1 Like

lol I had the same idea I opened a multi-sheet export  macro in separate pdf

I'll see if I can get the code clamps for this slddrw thing replacing the .pdf

1 Like

Hello

Since you have the myCADtools suite, you can use the "Integration" tool that should meet your expectations.

https://help.visiativ.com/mycadtools/2021/fr/Integration129.html

Attached is an example of an action 

- Condition if the document is a MEP, if the number of sheets is not 1

 - Then we do the operation of saving each sheet in a new MEP

Kind regards


example.mcact
3 Likes

I just quickly coded something that seems to work.

Just put in the 2nd line the path to your drwdot file.

Then it will have to be improved with some security so as not to launch it in any way.

For the moment you must imperatively open the MEP and then launch the macro (do not open a file in the meantime otherwise you will find your extracted files  in the same place as your open file)

'Mettre ci-dessous le chemin vers le modèle de Fond de plan
Const sDrTemplateLaser As String = "U:\Modèle de documents\Mise en plan - Fonds de plan\A4-DECOUPE-b.DRWDOT"

Sub main()

Dim swApp                   As SldWorks.SldWorks
Dim swModel                 As SldWorks.ModelDoc2
Dim swModel2                 As SldWorks.ModelDoc2
Dim swDraw                  As SldWorks.DrawingDoc
Dim swDraw2                 As SldWorks.DrawingDoc
Dim swSheet                 As SldWorks.Sheet
Dim vSheetNameArr           As Variant
Dim vSheetName              As Variant
Dim bRet                    As Boolean
Dim swExportPDFData         As SldWorks.ExportPdfData
Dim lErrors                 As Long
Dim lWarnings               As Long

Dim vSheetName2              As Variant
Dim i                       As Integer

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

' Is document active?

If swModel Is Nothing Then

    swApp.SendMsgToUser2 "A Drawing document must be active.", swMbWarning, swMbOk

    Exit Sub

End If
 

' Is it a Drawing document?

If swModel.GetType <> swDocDRAWING Then

    swApp.SendMsgToUser2 "A Drawing document must be active.", swMbWarning, swMbOk

    Exit Sub

End If


Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet

vSheetNameArr = swDraw.GetSheetNames
For Each vSheetName In vSheetNameArr

bRet = swDraw.ActivateSheet(vSheetName): Debug.Assert bRet

swDraw.ViewZoomtofit2


            swDraw.ActivateSheet vSheetName
            'Debug.Print "Feuille active:" & sheetName
            bRet = swDraw.Extension.SelectByID2(vSheetName, "SHEET", 0, 0, 0, False, 0, Nothing, 0)
            swModel.EditCopy
            Set swDraw2 = swApp.NewDocument(sDrTemplateLaser, 0, 0, 0)
            'On supprime la 1ère feuille existantes
            vSheetName2 = swDraw.GetSheetNames
            Set swModel2 = swApp.ActiveDoc
            Set swExt = swModel2.Extension
            
            
            bRet = swDraw2.PasteSheet(swInsertOption_MoveToEnd, swRenameOption_No)
            swDraw2.GetCurrentSheet.SetName vSheetName
            Set swModel2 = swApp.ActiveDoc
            
            '*********************************
            
            'On supprime la 1ère feuille existantes
            For i = 0 To UBound(vSheetName2) 'Boucle sur toutes les feuilles
            Debug.Print vSheetName2(i)
                If i = 0 Then
                    bRet = swExt.SelectByID2(vSheetName2(i), "SHEET", 0, 0, 0, False, 0, Nothing, 0)
                    'Supprimer la sélection
                    bRet = swExt.DeleteSelection2(0)
                End If
            Next
            
            '********************************
            swModel2.Extension.SaveAs Path & "\" & vSheetName & ".slddrw", 0, 0, Nothing, lErrors, lWarnings
Next vSheetName

End Sub

 

So now I'm fulfilled

between macro and integration!

Sorry Jm Savoyat I put sbadenis as the best answer "for those who don't have the mycad suite" 

But I love working with integration, plus I can incorporate it into an automated PDM task after checking of course.

2 Likes

@g.casters no worries! wink

1 Like

@JMSAVOYAT

example file of a higher version .... I thought I had the last update in 2021 SP2!  (I want the beta)

@g.casters 

A little patience, the myCADtools 2022 SP0 version should be available next week. We are fine-tuning the last details! smiley

Here's a screenshot of the example.

1 Like

the only tool where I install the SP0 since the beginning to say my level of patience.....

laugh actually!

But this feature in the example I tried to post to you has already been available for a long time!

1 Like