I should preface this with I know nothing about VB or programming. It's my kryptonite. I can patch together a sloppy macro based on other chunks of code but that's as good as it gets for me. I've searched everywhere today looking for a solution to this but couldn't find one.
I'm trying to rename the 3 default planes in a part/assembly to Front Plane, Top Plane, and Right Plane. This is so older files and downloaded vendor parts will better match our templates. I used the record macro method and got this chunk of code below. It works great if the 3 planes are named Plane1, Plane2, and Plane3, but not so good if they're named something else. Ultimately this will become part of a larger macro that updates files to our new template standard but this is the one section I cannot figure out.
I imagine this is easy-as-pie for you gurus, and was hoping someone could help me out.
Thanks!
---
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Plane1", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Plane1", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "Front Plane")
boolstatus = Part.Extension.SelectByID2("Plane2", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Plane2", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "Top Plane")
boolstatus = Part.Extension.SelectByID2("Plane3", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Plane3", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "Right Plane")
Part.ClearSelection2 True
End Sub
SolidworksApi macros