AnsweredAssumed Answered

Macro convert sheet metal automatically

Question asked by Fabrizio Bianchi on Mar 8, 2020


I would like to create a macro that could be convert in sheetmetal a part automatically without selecting the face.

Now i can convert sheetmetal with this code but i must select the face before and start the macro.

Is possible to do that automatically with a code of macro?
Thanks at all for the help 

Option Explicit

Dim swApp As SldWorks.SldWorks

Dim Part As SldWorks.ModelDoc2

Dim boolstatus As Boolean
Dim spessore As Integer
Dim i As Long
Dim lErrors As Long
Dim lWarnings As Long
Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
Part.ShowNamedView2 "*Anteriore", 1

boolstatus = Part.Extension.SelectByRay(10.022499999812, -29.5509563271198, -1.13100000001151, 0, 0, -1, 1.81577731894109E-03, 2, False, 0, 0)
'boolstatus = Part.FeatureManager.InsertConvertToSheetMetal2(0.02, False, True, 0.001, 0.001, swSheetMetalReliefTypes_e.swSheetMetalReliefTear, 0.5, 1, 0.27, False)
boolstatus = Part.FeatureManager.InsertConvertToSheetMetal2(0.02, False, True, 0.001, 0.001, 2, 0.5, 1, 0.5, False)
boolstatus = Part.Extension.SelectByID2("Sconosciuto", "BROWSERITEM", 0, 0, 0, False, 0, Nothing, 0)
Part.SetMaterialPropertyName2 "Default", "C:/ProgramData/SolidWorks/SOLIDWORKS 2018/Materiali personalizzati/Materiali personalizzati.sldmat", "Ferro"
Part.ClearSelection2 True
Part.ForceRebuild3 (False)
boolstatus = Part.Save3(swSaveAsOptions_Silent, lErrors, lWarnings)

End Sub