AnsweredAssumed Answered

macro to name faces

Question asked by 1-F2ZMME on Mar 4, 2009
Latest reply on Jun 12, 2009 by Ahmad Gad
This macro works to name up to six selected faces, but I would like it to name all faces in a part just by selecting the entire part - the SelMgr is not right I think.

thanks very much for the help.

Dim swApp As SldWorks.SldWorks
Dim Model As SldWorks.ModelDoc2
Dim Part As SldWorks.PartDoc
Dim SelMgr As SldWorks.SelectionMgr
Dim selFace1 As SldWorks.Face2
Dim selFace2 As SldWorks.Face2
Dim selFace3 As SldWorks.Face2
Dim selFace4 As SldWorks.Face2
Dim selFace5 As SldWorks.Face2
Dim selFace6 As SldWorks.Face2
Dim swFace As SldWorks.Face2
Dim swFaceName, messageString As String
Dim ret As Boolean
Dim swSelData As SldWorks.SelectData
Dim swEnt As SldWorks.Entity

Sub main()
Set swApp = Application.SldWorks
Set Model = swApp.ActiveDoc
Set Part = Model
Set SelMgr = Model.SelectionManager()

Set selFace1 = SelMgr.GetSelectedObject5(1)
ret = Part.SetEntityName(selFace1, "Face1")
Set selFace2 = SelMgr.GetSelectedObject5(2)
ret = Part.SetEntityName(selFace2, "Face2")
Set selFace3 = SelMgr.GetSelectedObject5(3)
ret = Part.SetEntityName(selFace3, "Face3")
Set selFace4 = SelMgr.GetSelectedObject5(4)
ret = Part.SetEntityName(selFace4, "Face4")
Set selFace5 = SelMgr.GetSelectedObject5(5)
ret = Part.SetEntityName(selFace5, "Face5")
Set selFace6 = SelMgr.GetSelectedObject5(6)
ret = Part.SetEntityName(selFace6, "Face6")

End Sub