Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
AlexFielder
in reply to: PaulMunford

Hi @PaulMunford

 

Long time no see around these parts :winking_face:

 

I ran your code and it worked the first time, but not after that in a newly created assembly file.

 

The reason for this is because you were changing the name (of the active lightingstyle) to the string you desired with this line, not changing the active lightingstyle to it:

 

oAssy.ActiveLightingStyle.Name = "Grid Light"

I've knocked up this simple rule:

 

Dim oAssy As AssemblyDocument = ThisApplication.ActiveDocument

Dim oLightStyleName As String 

oLightStyleName = oAssy.ActiveLightingStyle.Name

MessageBox.Show(oLightStyleName, "Title")

Dim lightingstyletochangeto As LightingStyle = oAssy.LightingStyles.Item("Grid Light")
If Not oAssy.ActiveLightingStyle.Name = lightingstyletochangeto.Name Then
	oAssy.ActiveLightingStyle = lightingstyletochangeto
	InventorVb.DocumentUpdate()
Else
	MessageBox.Show("We're already using the desired lighting style!")
End If

Which appears on the surface to answer your question. When it runs however, the active lightingstyle on the "View" tab of the Inventor interface doesn't seem to update so there must either be:

  1. a bug OR
  2. a missing update function I haven't used to update the Inventor interface

I'm not sure which without further investigation.

 

Cheers,

 

Alex.