AnsweredAssumed Answered

Change Face Appearance In Macro

Question asked by Tyler Folger on May 6, 2019
Latest reply on May 8, 2019 by Peter Brinkhuis

Hello. I'm trying to create a macro that will supplement the custom properties builder so novice users have a nice UI to customize one of our common parts. I'm wondering if there's a way to change the appearance of a model face in the API. Basically, I'm using custom properties to drive the part's base appearance, and also to give the option to add a colored stripe to the part. I already have functioning code to change the base appearance, but now I want the macro to take a saved selection set of faces, and apply the stripe appearance to them (without changing the base appearance or the appearance assignments of any other faces). Can this be done?

 

Note that I'm trying to avoid just changing the RGB value of an appearance. I would rather attach a different default appearance to the faces, if possible.

 

*Bonus points if you can tell me what's wrong with my code for selecting the faces.

 

Thank you.

 

 

 

 

 

    'Declare Variables
    Dim swApp               As SldWorks.SldWorks
    Dim swModel             As SldWorks.ModelDoc2
    Dim swFeatureManager    As SldWorks.FeatureManager
    Dim swModelDocExt       As SldWorks.ModelDocExtension
    Dim swCustProp          As SldWorks.CustomPropertyManager
    Dim WireSize            As String
    Dim WireSelectState     As String
    Dim UserSizeSelection   As String
    Dim swEquationMgr       As SldWorks.EquationMgr
    Dim ValOut              As String
    Dim PropName            As Variant
    Dim IDNewValue          As Double
    Dim ODNewValue          As Double
    Dim BaseColor           As String
    Dim StripeColor         As String
    Dim ConfigurationSelect As String

'Function that selects model faces from a selection set based on the configuration the user has selected
Function GetSelectionSet(ConfigurationSelect As String)


    'Declare Variables
    Dim swSelectionSetFolder    As SldWorks.SelectionSetFolder
    Dim StripeSelectionSet      As SldWorks.SelectionSet
    Dim StripeFace              As SldWorks.Face2
    
    'Set Variables
    Set swSelectionSetFolder = swFeatureManager.GetSelectionSetFolder
    Set StripeSelectionSet = swSelectionSetFolder.GetSelectionSetByName("Stripe Faces " & ConfigurationSelect)
    
    'Select Faces
    Set StripeFace = StripeSelectionSet.Select()


End Function

Outcomes