I am very new to VBA (but competent in Python) and would like some help on the following problem as I am having trouble writing a functioning macro for SolidWorks:
I am setting up an automated workflow for the production of sheetmetal parts which are exported as 0 thickness polysurfaces from Rhinoceros as STEP files. I am also automating the export of a text file which identifies the fixed face, bend edges, thickness and radius parameters for each STEP file which I would like to convert into a SheetMetal Part in SW.
Each text file looks like this:
"FACE" 37.0334 3.6163 0.0
"EDGE" 36.4862 3.6163 0.0
"EDGE" 36.4862 3.3663 0.1724
"EDGE" 37.5807 3.6163 0.0
"EDGE" 37.0334 3.3663 0.0
The corresponding VBA macro looks like this:
Dim swApp As Object
Dim part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Set swApp = Application.SldWorks
boolstatus = swApp.LoadFile2("C:\Users\userName\Desktop\Part1.stp", "r")
Set part = swApp.ActiveDoc
Open "C:\Users\g.maciocci\Desktop\FACE_EDGE_LIST.txt" For Input As #1
Do While Not EOF(1)
Input #1, SelType, X, Y, Z
Set boolstatus = part.Extension.SelectByID2("", SelType, X, Y, Z, True, 0, Nothing, 0) <----------- THIS IS WHERE I GET A TYPE MISMATCH ERROR THROWN
boolstatus = part.FeatureManager.InsertConvertToSheetMetal2(0.003, False, False, 0.003, 0.002, 0, 0.5, 0, 0.5, False)
longstatus = part.SaveAs3("C:\Users\userName\Desktop\Part1.SLDPRT", 0, 2)
Now I know this is down to totally illiterate use of the VBA language!
What I would like to do is take the SelType ("FACE" or "EDGE") from my text file and the x,y,z coordinates of the selection, pass them to SelectByID2 in order to define the fixed face and bend edges for the InsertConvertToSheetMetal2.
I would also like to loop through a large number of STEP files and associated text files (defining fixed face and bend edges for each) converting to sheet metal, saving and closing each one.
Could someone please help me debug the code?