I use the attached macro to set colors inside parts or assemblies. Select a face or edge or point or feature or... anywhere and call any of the Color_XXX macros.
QuickColors.swp.zip 74.0 KB
Is it compatible with SW2010?
IMHO yes, otherwise you should get an error 2 lines above on swSelectType_e.swSelFTRFOLDER, or I'm wrong?
Anyway, I've written that macro with SW2016, so maybe the compiler has a little issue with the references:
Try to remove the reference to "SldWorks 2010 Type Library", save, close and reopen, then set the reference again.
If that doesn't work change the Dim line to
Dim swFtrFolder As Object 'SldWorks.FeatureFolder
I changed Dim line as you write and macro became work.
But if I choose boss-extrude feature then macro change color for all faces of the part (solid). Is it correct? If I choose move face feature I got an error.
I need to choose move face feature and change color only for move faces.
Please see attached files.
I need to change color only for faces moved by "Move face" feature.
I.e. I run macro, choose "Move face" feature in features manager, and moved faces change its color (see attached pics). But using your macro I choose "move face" and all the body change it color (not only moved faces). Also I get an error (see screenshot 1).
Maybe Im doing something wrong.
Is it possible at all?
Dim swApp As SldWorks.SldWorks
Dim Part As ModelDoc2
Dim selmgr As SelectionMgr
Dim myFeat As Feature
Dim sa As Variant
Dim myFace As Face2
Dim i As Integer
Dim vProps As Variant
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
If Part Is Nothing Then Exit Sub
If Part.GetType <> 1 Then Exit Sub
Set selmgr = Part.SelectionManager
If selmgr.GetSelectedObjectCount2(-1) <> 1 Then Exit Sub
If selmgr.GetSelectedObjectType3(1, -1) <> swSelBODYFEATURES Then Exit Sub
Set myFeat = selmgr.GetSelectedObject6(1, -1)
sa = myFeat.GetAffectedFaces
If IsEmpty(sa) Then Exit Sub
For i = 0 To UBound(sa)
Set myFace = sa(i)
vProps = myFace.GetMaterialPropertyValues2(1, Empty)
vProps(0) = 0.5
vProps(1) = 1
vProps(2) = 0.5
vProps(3) = 0
vProps(4) = 0
vProps(5) = 0
vProps(6) = 0
vProps(7) = 0
vProps(8) = 0
myFace.SetMaterialPropertyValues2 vProps, 1, Empty