Changing photometric parameters

Changing photometric parameters

franjavigarciavalencia
Enthusiast Enthusiast
1,011 Views
3 Replies
Message 1 of 4

Changing photometric parameters

franjavigarciavalencia
Enthusiast
Enthusiast

Hello

 

I want to programatically change the value of Intensity, Color and Tilt Angle (among other parameters) within a Lighting family.

 

I have been able to change all other parameters well, but these three haven't worked.

 

The Initial Intensity and Color do not return any kind of error, but do not change their value. I have checked the storageType and they work with intergers, and I am entering valid numbers, so I do not know what is the problem.

 

Captura.JPGCaptura2.JPG

I assume i have to access the Luminous Flux and Color Temperature, but I can't find out how.

 

The problem I have with the Tilt Angle is different. I enter a valid amount (between -180 and 180) and of double type (the one it's stored as) and it still gives an error, saying I am out of bounds.

 

Captura3.jpg

Thanks.

0 Likes
Accepted solutions (2)
1,012 Views
3 Replies
Replies (3)
Message 2 of 4

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @franjavigarciavalencia ,

The parameters you are trying to change are type parameters not instance parameters.

Element e;
ElementType ET = doc.GetElement(e.GetTypeId()) as ElementType;

then change the parameter of the type

Parameter tiltAngle = ET.get_Parameter(BuiltInParameter.FBX_LIGHT_SPOT_TILT_ANGLE);
tiltAngle.Set(1.04666);

 suppose you want to set the angle value to 60

double tiltAngle=(60*3.14)/180=1.04666;

Parameter initialColor = ET.get_Parameter(BuiltInParameter.FBX_LIGHT_INITIAL_COLOR_TEMPERATURE);                
initialColor.Set(4000);
Parameter luminuousFlux = ET.get_Parameter(BuiltInParameter.FBX_LIGHT_LIMUNOUS_FLUX);
luminuousFlux.Set(1379);

I hope this helps.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 4

franjavigarciavalencia
Enthusiast
Enthusiast

Hello @naveen.kumar.t 

 

Thank you for your answer.

 

I am working from within the family, so I am using the FamilyManager class. I have tried your suggestions, and the Tilt one works perfectly.

 

The other two return Null Argument exceptions when setting the parameters.

 

 

FamilyParameter familyParameter = doc.FamilyManager.get_Parameter(BuiltInParameter.FBX_LIGHT_LIMUNOUS_FLUX);
doc.FamilyManager.Set(familyParameter, 2000);

 

 

Originally, when I got the parameter by name it just didn't set the parameters, but didn't return any error whatsoever.

I have tried to get the Element Type you use, but as this is not and Instance it fails aswell.

 

 

0 Likes
Message 4 of 4

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @franjavigarciavalencia ,

You can use the below code to set the photometric parameters in a family document

 

LightFamily LF = LightFamily.GetLightFamily(doc);
FamilyType FT = doc.FamilyManager.CurrentType;  
LightType lighttyp = LF.GetLightType(0);

 

To set INITIAL COLOR

 

if (lighttyp != null)
                {
                    //SET INITIAL COLOR
                    InitialColor iniColor = lighttyp.GetInitialColor();
                    if (iniColor is CustomInitialColor)
                    {
                        CustomInitialColor custom = iniColor as CustomInitialColor;
                        double colorTemperature = custom.Temperature;

                        // Set new value for color temperature and set modified initial color to LightType.
                        custom.Temperature = 3450.0;
                        lighttyp.SetInitialColor(custom);
                    }
                    else if (iniColor is PresetInitialColor)
                    {
                        PresetInitialColor preset = new PresetInitialColor(ColorPreset.HighPressureSodium);
                        lighttyp.SetInitialColor(preset);
                    }
                }

 

To set INITIAL INTENSITY

 

LightType lighttyp = LF.GetLightType(0);       
                if (lighttyp != null)
                {
                 //SET INITIAL INTENSITY
                  InitialIntensity initialIntensity = lighttyp.GetInitialIntensity();                   
                    if (initialIntensity is InitialFluxIntensity)
                    {                        
                          InitialFluxIntensity fluxIntensity = initialIntensity as InitialFluxIntensity;
                          double fluxValue = fluxIntensity.Flux;

                          // Set new value for Flux proeprty and set modified InitialIntensity to LightType.
                          fluxIntensity.Flux = 100.5;
                          lighttyp.SetInitialIntensity(fluxIntensity);

                          // Create a InitialWattageIntensity and set it to LightType.                       
                          InitialWattageIntensity wattageIntensity = new InitialWattageIntensity(1.1,1.1);
                          lighttyp.SetInitialIntensity(wattageIntensity);
                    }
                    else if (initialIntensity is InitialIlluminanceIntensity)
                    {
                          InitialIlluminanceIntensity illum = initialIntensity as InitialIlluminanceIntensity;
                          double illumValue = illum.Illuminance;

                          illum.Illuminance = 5000;
                          lighttyp.SetInitialIntensity(illum);
                     } 
                } 

 

If you any doubts, feel free to ask.

I hope this helps.

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network