API: Adding Spot Light

Discussion in 'SolidWorks' started by Corey Scheich, Jun 14, 2004.

  1. 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
     
    Corey Scheich, Jun 14, 2004
    #1
  2. I tried the code and got the same thing. I even tried manually adjusting
    the settings to match the manually added one. I also tried saving the file
    and then reopening it.
     
    Evan T. Basalik, Jun 16, 2004
    #2
  3. 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
     
    Corey Scheich, Jun 18, 2004
    #3
  4. 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
     
    Mike J. Wilson, Jun 18, 2004
    #4
  5. 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
     
    Corey Scheich, Jun 18, 2004
    #5
  6. 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
     
    Corey Scheich, Jun 18, 2004
    #6
  7. 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
     
    Mike J. Wilson, Jun 18, 2004
    #7
  8. 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

    Anyway I later added the lock to model and moved the location.
     
    Corey Scheich, Jun 18, 2004
    #8
  9. I see! I was able to reproduce the problem without the macro.
    I never noticed that before.

    Mike Wilson
     
    Mike J. Wilson, Jun 18, 2004
    #9
  10. 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
     
    Corey Scheich, Jun 21, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.