Guck mal in der SWX-API Hilfe
Hier das Bsp für Baugruppenteile einfärben: (Gesucht wurde nach: MaterialPropertyValues)
Change Material Properties Example (VB)
This example shows how to change the color of the selected assembly component.
'----------------------------------------------------
'
' Preconditions:
' 1) Assembly is open
'
' 2) A component is selected
'
' Postconditions:
' 1) Color of selected component is changed to blue
'
' 2) Selection set is cleared
'
'
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCompModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swComp As SldWorks.Component2
Dim vMatProp As Variant
Dim bRet As Boolean
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swComp = swSelMgr.GetSelectedObjectsComponent2(1)
vMatProp = swComp.MaterialPropertyValues
If IsEmpty(vMatProp) Then
' Empty if no component-level colors specified,
' so get from underlying model
Set swCompModel = swComp.GetModelDoc
If swCompModel Is Nothing Then
' Component is lightweight
Exit Sub
End If
vMatProp = swCompModel.MaterialPropertyValues
End If
Debug.Print "File = " & swModel.GetPathName
Debug.Print " Comp = " & swComp.Name2 & " (" & swComp.ReferencedConfiguration & ")"
Debug.Print " State = " & swComp.GetSuppression
Debug.Print " Suppressed = " & swComp.IsSuppressed
Debug.Print " Hidden = " & swComp.IsHidden(False)
Debug.Print " RGB = [" & vMatProp(0) * 255# & ", " & vMatProp(1) * 255# & ", " & vMatProp(2) * 255# & "]"
Debug.Print " Ambient = " & vMatProp(3)
Debug.Print " Diffuse = " & vMatProp(4)
Debug.Print " Specular = " & vMatProp(5)
Debug.Print " Shininess = " & vMatProp(6)
Debug.Print " Transparency = " & vMatProp(7)
Debug.Print " Emission = " & vMatProp(8)
' Force component color to blue
vMatProp(0) = 0#
vMatProp(1) = 0#
vMatProp(2) = 1#
swComp.MaterialPropertyValues = vMatProp
' Deselect face so we can see new colour
swModel.ClearSelection2 True
End Sub
'-----------------------------------------------------
------------------
Gruß, der Teddibaer
Besucht mich doch mal ...
----------------
Es gibt eine Theorie, nach der die Konzentration von Dummheit an bestimmten Orten besonders hoch ist.
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP