Hallo Dieter,
aus der Solidworks Hilfe:
Change Color of Face Example (VB)
This example shows how to change the color of the selected face to blue.
'-----------------------------------------------------
'
' Preconditions:
' (1) Part or assembly is open.
' (2) Face is selected.
'
' Postconditions: Color of selected face is changed to blue.
'
'------------------------------------------------------
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFace As SldWorks.face2
Dim vFaceProp As Variant
Dim bRet As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swFace = swSelMgr.GetSelectedObject5(1)
vFaceProp = swFace.MaterialPropertyValues
If IsEmpty(vFaceProp) Then
' Is empty if face-level colors were not specified, so get them from underlying model
vFaceProp = swModel.MaterialPropertyValues: Debug.Assert Not IsEmpty(vFaceProp)
End If
' New color
bRet = swModel.SelectedFaceProperties( _
RGB(0, 0, 255), _
vFaceProp(3), vFaceProp(4), vFaceProp(5), _
vFaceProp(6), vFaceProp(7), vFaceProp(8), _
False, ""): Debug.Assert bRet
' Deselect face to see new color
swModel.ClearSelection2 True
End Sub
'-----------------------------------------------------
Gruß Harald
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP