API: Adding Spot Light

I added a spotlight throught API and it shows up in the tree the settings are all what I set it is on but yet it doesn't show. If I add one without API it does show, and when I render the API added one it shows as expected. Am I missing something.

Corey Scheich

' C:\DOCUME~1\cscheich\LOCALS~1\Temp\swx2844\Macro1.swb - macro recorded on

05/18/04 by cscheich ' **************************************************************************** ** Dim swApp As SldWorks.SldWorks Dim Part As SldWorks.ModelDoc2 Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim FeatureData As Object Dim Feature As Object Dim Component As Object Dim LightID As Long Dim LightProps As Variant Dim LightProps2 As Variant Dim NewName As String Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

LightProps = Part.LightSourcePropertyValues(2) Part.AddLightSource "CS#1", 2, "Copy of Spot1"

'I tried with and without the next line NewName = Part.AddLightToScene("Copy of Spot1")

Part.LockLightToModel (Part.GetLightSourceCount), True Part.LightSourcePropertyValues(Part.GetLightSourceCount) = LightProps

LightProps2 = Part.LightSourcePropertyValues(Part.GetLightSourceCount)

Part.GraphicsRedraw End Sub

Reply to
Corey Scheich
Loading thread data ...

You know what Evan I think it is working but it only seems to show if you move it to a location above a round part for some reason a direct on spotlight doesn't seem to illuminate a flat surface. Except when rendered. It also seemed to show up better when moved so the cone hits a perpendicular wall. Should I consider this a bug or what?

Corey

****************************************************************************
Reply to
Corey Scheich

Your target and position are exactly the same. This is causing the light not to work.

If you edit the light's properties and modify it's position, you can see it.

Mike Wilson

Reply to
Mike J. Wilson

Mike,

You are correct, but after moving the position of it 300 in the Y it still didn't shed any light on the flat surface of the model. I believe that under the light there should be a brighter circle. This shows up only when rendered. Though if I bounced it off of a perpendicular surface it added a bit of light to everything, rendered or not. Infact none of my spot lights seem to be adding light to any flat surface that they shine directly down on. Yet they show on rounded surfaces and perpendicular surfaces just as I would expect them to.

Corey

Reply to
Corey Scheich

After some more testing it seems that if the flat surface with a spot shining directly on it has any boundry outside the spot light that no light is shed on it yet if the surface is completely contained within the spot it is correctly lit. I reported it to my VAR.

Corey

Reply to
Corey Scheich

I also noticed that your "Cone Angle" was set to "0" and that "Lock to Model" was disabled. Is there a reason why you don't want your light locked to the model?

Once you set those, the light works fine.

Mike Wilson

Reply to
Mike J. Wilson

What the code does is it creates a new spot light and coppies the preferences from "Spot1" Which happened to be the third light in the model here is the line that gets the settings from the third light in the model

LightProps = Part.LightSourcePropertyValues(2)

anyway those are set and the light isn't showing properly. I am going to send you an mpeg to show you what I am talking about.

Corey

Reply to
Corey Scheich

I see! I was able to reproduce the problem without the macro. I never noticed that before.

Mike Wilson

Reply to
Mike J. Wilson

I don't know what priority they will put on it but it has been submitted to the propper authorities. It would be nice to know where your spot is going to show up without rendering.

Corey

Reply to
Corey Scheich

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.