i can't figure out how to delete all the custom lights from a part.
i'm a bit vb illiterate. maybe one of you experts could enlighten me with a nice macro?
This will delete all direction lights from a part:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Do While swModel.GetLightSourceCount > 1
The light source index starts at 1. The Ambient light, which is undeletable, is index 0. Whenever you delete a directional light, any remaining directional lights drop down in the index, so you can't crawl forward with a For loop and instead must use a Do Loop like above.
If, for some reason, a directional light can't be deleted, then this code will result in an infinite loop. For safety reasons you might include a counter that eventually triggers leaving the loop if the counter hits a certain value.
SolidWorks API Tutorials
Retrieving data ...