Render Style in Assembly Part

Render Style in Assembly Part

mk92
Collaborator Collaborator
344 Views
1 Reply
Message 1 of 2

Render Style in Assembly Part

mk92
Collaborator
Collaborator

Hello,

 

i have written some code and it works well until the last line. The Name of the Feature is shown correctly but the RenderStyle doesn't change to Yellow.

The Error is: Wrong Parameter

 

Anyone any idea whats the problem?

 

Regards

 

Code:

 

Dim oAsmDoc As AssemblyDocument 
oAsmDoc = ThisApplication.ActiveDocument 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition

Dim oOccurrence As ComponentOccurrence
oOccurrence = oAsmCompDef.Occurrences.Item(1)

Dim oPartDoc As PartDocument
oPartDoc = oOccurrence.Definition.Document

' Get the second feature. 
Dim oFeature As PartFeature 
oFeature = oPartDoc.ComponentDefinition.Features.Item(1) 

MessageBox.Show(oFeature.Name)

oFeature.SetRenderStyle(kOverrideRenderStyle, oPartDoc.RenderStyles.Item("Yellow"))
0 Likes
345 Views
1 Reply
Reply (1)
Message 2 of 2

jacob39NGR
Participant
Participant
  1. Ensure kOverrideRenderStyle is a valid constant for SetRenderStyle.
  2. Verify "Yellow" exists in oPartDoc.RenderStyles. You can loop through oPartDoc.RenderStyles to check.
  3. Confirm oFeature supports the SetRenderStyle method.
  4. If the feature type is known, consider type casting oFeature
0 Likes