I have made a VBA code to create a new part in Solidworks and select the Front Plane for sketching, as below:
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Set swApp = Application.SldWorks
Set Part = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2021\templates\Part.prtdot", 0, 0, 0)
boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
The code is working perfectly.
However, when I try to do the same thing with the Matlab code, it is NOT working, My Matlab code is as below:
Part=invoke(swApp,'NewDocument','C:\ProgramData\SolidWorks\SOLIDWORKS 2021\templates\Part.prtdot', 0, 0, 0);
The error has occurred at the final line. It is said that argument 8th of the method "SelectByID2" is not correct. I do not know why, because I have directly converted from VBA code.
If someone could help me to solve the problem in Matlab code, this would be greatly appreciated.
Thanks in advance.