Get Entity By Name Example (VBA)
This example shows how to get a face by specifying
its name. Then, the face name is changed to "NewFaceName". This
process is commonly used with standardized parts where names can be given
to objects and the objects can be accessed later.
'---------------------------------------------
Public Sub GetFaceByName( faceName
)
Dim swApp As Object
Dim Part As Object
Dim Face As Object
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
Set Face = Part.GetEntityByName(faceName, 2)
ret = Part.DeleteEntityName(Face)
ret = Part.SetEntityName(Face, "NewFaceName")
If (ret = True)
Then
swApp.SendMsgToUser "Successfully changed
face name."
Else
swApp.SendMsgToUser "Error changing face
name."
End If
End Sub