AnsweredAssumed Answered

Propagate visual properties when saving body as part

Question asked by Peter Brinkhuis on Sep 9, 2020
Latest reply on Sep 10, 2020 by Peter Brinkhuis

Hi all,


Do you know if there is a way to propagate (aka copy) the visual properties (aka appearances) when you save a body to a new part? I am only able to achieve this via de UI and not via code. I mean this option in the UI.



The latest method for achieving save to new part is:

2020 SOLIDWORKS API Help - SaveToFile3 Method (IPartDoc) 


I recorded a macro and it uses the first version of this method. So I updated it to this working version. Update your username in the path and you're good to go. I have also added a weldment part (made in SW2019) for you to test with.


Sub main()
Dim swApp As ISldWorks
Dim swModel As ModelDoc2
Dim swPart As PartDoc
Dim errors As Long, warnings As Long

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

swModel.Extension.SelectByID2 "Square tube 20 X 20 X 2(1)[1]", "SOLIDBODY", 0, 0, 0, False, 0, Nothing, 0
swPart.SaveToFile3 "C:\Users\peter\Desktop\weldment 2019 body 1.SLDPRT", _
swSaveAsOptions_e.swSaveAsOptions_Silent, swCutListTransferOptions_e.swCutListTransferOptions_FileProperties, False, "", errors, warnings
End Sub