PDA

View Full Version : acrender.arx



ike.eisenstadt
2004-12-10, 03:51 PM
I have written some code that allows me to manipulate multiple lights in a drawing (change all their intensities, etc...). I believe that most of the information that describes a particular light is stored in the xdata for that block. but I am having trouble determining just where beam and field angle info is kept...

In fact can anyone describe what the 22 pieces of xdata for a spotlight are??

Thanks

Oh btw---Here is the little piece of code that changes all the spotlights intensity (at least if their name stats with "HL"

Sub DimHouselights()
'Variable Dimesions Block

Dim Element As Object
Dim ArrayAttributes As Variant
Dim xdataOut, result As Variant
Dim xtypeOut As Variant

'{End Variable Dimensions}

On Error Resume Next
result = InputBox("Set lights at??")
For Each Element In ThisDrawing.ModelSpace
'Check for attributes within blocks
If Element.EntityType = 7 Then 'Test if it is a block
If Element.Name = "sh_spot" Then
ArrayAttributes = Element.GetAttributes
If (Left$(ArrayAttributes(0).TextString, 2) = "HL") Then
Element.GetXData "", xtypeOut, xdataOut
xdataOut(5) = result
Element.SetXData xtypeOut, xdataOut
End If
End If
End If
Next
End Sub

RobertB
2004-12-10, 07:23 PM
Good question. I haven't looked at that myself.

ike.eisenstadt
2004-12-11, 02:16 PM
Well, So far I have figured this much out:

xDataOut(0)-----Inserting Application (in my case ave_render)

xDataOut(1)-----"{"---I think it's a field delimiter before the light identification info---doesn't seem to change

xDataOut(2)-----??? (Not Sure what this is yet---in my case it's been 0)

xDataOut(3)-----Lights name as a string

xDataOut(4)-----Array [0-2] of Double---Seems to be the lights Target

xDataOut(5)-----Lights intensity as a double

xDataOut(6)-----Array [0-2] of Double---Mostly been all 1's--I think its the lights color (in this case white)
xDataOut(7)-----"{"---I think it's another field delimiter

xDataOut(8)----Integer---So far its been 545--Not sure what it is

xDataOut(9)----Integer---So far its been 128--Not sure what it is

Here's where the lights beam pattern are (10 and 11)--I've only figured out the formula for lights with no attenuation features


xDataOut(10)--0.5*Field angle (So essentially 0-80 for a spotlight)

xDataOut(11)--((1-(beam/field))*(Field/2))

So--With a Beam of 26deg, and a field of 73deg...

xDataOut(10)=36.5
xDataOut(11)=23.5

xDataOut(12)---as a double---Not sure what it is (so far its been 3)

xDataOut(13)-----"}"---I think it's another field delimiter
xDataOut(14)-----"{"---I think it's another field delimiter

xDataOut(15)-(18)---all integers Not sure what they are

xDataOut(19)-(20)---Doubles---Don't know

xDataOut(21)-(22)--- )-----"}"---I think it's another field delimiter

I'll keep playing with the params--and see if I can find out more--

any help from the gurus would be appreciated


oops almost forgot...Heres some more helpful code---If the name of the Spotlight starts with "HL" it will change the beam and field angles for the light.

Sub ChgBeamAndField()
'Variable Dimesions Block

Dim Element As Object
Dim ArrayAttributes As Variant

Dim xdataOut, Beam, Field As Variant
Dim xtypeOut As Variant

'{End Variable Dimensions}

On Error Resume Next
Beam = InputBox("Set lights Beam angle at??")
Field = InputBox("Set lights Field angle at??")
If Field > 160 Then Field = 160


For Each Element In ThisDrawing.ModelSpace
'Check for attributes within blocks
If Element.EntityType = 7 Then 'Test if it is a block
If Element.Name = "sh_spot" Then
ArrayAttributes = Element.GetAttributes
If (Left$(ArrayAttributes(0).TextString, 2) = "HL") Then
Element.GetXData "", xtypeOut, xdataOut
xdataOut(10) = Field / 2
xdataOut(11) = (1 - (Beam / Field)) * (Field / 2)
Element.SetXData xtypeOut, xdataOut
End If

End If
End If
Next


End Sub