How to modify some parameters value (like "Luminous Flux") inside a family doc

How to modify some parameters value (like "Luminous Flux") inside a family doc

Anonymous
Not applicable
1,800 Views
7 Replies
Message 1 of 8

How to modify some parameters value (like "Luminous Flux") inside a family doc

Anonymous
Not applicable

Hello all,


I need to change the electrical properties of some Revit family files, related to lighting fixtures (lighting category).

I've found some interesting things at http://thebuildingcoder.typepad.com/blog/2009/04/deeper-parameter-exploration.html . Anyway, as far as I understand it seems to concern family instances inside a revit project.

 

I have to make these changes directly in the .rfa files.

For instance, I would like to change the "Initial Intensity" by giving the value of the "Luminous Flux".

How to reach the BuiltInParameter FBX_LIGHT_INITIAL_INTENSITY and FBX_LIGHT_LIMUNOUS_FLUX in the FamilyManager object ?

If not possible, is there a workaround ?

 

Regards

 

Jean-Robert

1,801 Views
7 Replies
Replies (7)
Message 2 of 8

MarryTookMyCoffe
Collaborator
Collaborator

I'm not sure about that specific FamilyParametr but this is how I usually do it.

1 i get family document change parameters

Document familydoc = doc.EditFamily(some_family);
FamilyParameterSet FPS =  familydoc.FamilyManager.Parameters;
foreach ( FamilyParameter fP in  FPS)
{
 if(fP.Definition.Name == "some name of parameter")
 {
  familydoc.FamilyManager.Set(fP, someKindOfValue);
 }
}

2 than if it didn't change, try: document.LoadFamily(familydoc) or you can experiment with saving files and than load it.

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 3 of 8

豪三品8170
Explorer
Explorer

I have just bumped into exactly the same problem. Did you find a solution or workaround since then?

0 Likes
Message 4 of 8

Revitalizer
Advisor
Advisor

Hi,

 

in the RevitAPI.chm, there are a few code samples for LightType and its members.

For example on "LightFamily.SetLightDistributionStyle" page.

 

There you can see how to get LightTypes in the family document:

 

public void ModifyLightDistributionStyle(Document familyDoc)
{
    // Get the light family from the static method.
    LightFamily lightFamily = LightFamily.GetLightFamily(familyDoc);

    // Set the light distribution style to PhotometricWeb
    lightFamily.SetLightDistributionStyle(LightDistributionStyle.PhotometricWeb);

    // After light shape style set to PhotometricWeb, each tyoe returns a CircleLightShape instance,
    for (int index = 0; index < lightFamily.GetNumberOfLightTypes(); index++)
    {
        LightType lightData = lightFamily.GetLightType(index);
        PhotometricWebLightDistribution lightDistribution = 
            lightData.GetLightDistribution() as PhotometricWebLightDistribution;
        lightDistribution.PhotometricWebFile = @"C:\IES\1x4 2Lamp.ies"; // input a full file path here.
        lightDistribution.TiltAngle = Math.PI / 6;    // use radian value to set
        lightData.SetLightDistribution(lightDistribution);  // set back
    }
}

Once you have a LightType, you can set its properties, for example the initial intensity.

 

Depending on which BuiltInParameter you want to adress, use

 

FBX_LIGHT_LIMUNOUS_FLUX
lightData.SetInitialIntensity(new InitialFluxIntensity(lumen));

FBX_LIGHT_LIMUNOUS_INTENSITY
lightData.SetInitialIntensity(new InitialIlluminanceIntensity(1, candela));

FBX_LIGHT_WATTAGE
lightData.SetInitialIntensity(new InitialWattageIntensity(1, watt));

FBX_LIGHT_EFFICACY
lightData.SetInitialIntensity(new InitialLuminousIntensity(lumenPerWatt));

 

Also, there is a code sample for setting the initial color, on page "LightType.SetInitialColor":

 

public void SetInitialColorProperty(LightType lightType)
{
    InitialColor initialColor = lightType.GetInitialColor();
    if (initialColor is CustomInitialColor)
    {
        CustomInitialColor custom = initialColor as CustomInitialColor;
        double colorTemperature = custom.Temperature;

        // Set new value for color temperature and set modified initial color to LightType.
        custom.Temperature = 3450.0;
        lightType.SetInitialColor(custom);

        // Create a PresetInitialColor and set it to LightType.
        PresetInitialColor preset = new PresetInitialColor(ColorPreset.Halogen);
        lightType.SetInitialColor(preset);

    }
}

And so on.

RevitAPI.chm says "Since: 2013".

 

Revitalizer

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 8

豪三品8170
Explorer
Explorer

I really appreciate your detailed answer. And yes, it solved my problem completely!

(I wonder why I couldn't find anything about the Autodesk.Revit.DB.Lighting namespace while I was googling around...)

 

Thank you!!

tmishina

0 Likes
Message 6 of 8

franjavigarciavalencia
Enthusiast
Enthusiast

Hello, I have tried using this, but it seems that my LightFamily has no LightTypes in it (lightFamily.GetNumberOfLightTypes() = 0, although it does have a light source where I can load a photometric IES file) so I am at a loss as to what does this class control and how to create/manipulate it.

 

I am working from within the family itself, in case that may be the problem.

 

Thank you for your help.

0 Likes
Message 7 of 8

Revitalizer
Advisor
Advisor

Hi,

 

just a guess.

There may be a relation between LightTypes and FamilyTypes.

 

In the Family document, after you have added a new FamilyType:

Does GetNumberOfLightTypes() return more than zero, then?

Perhaps family document needs regeneration or commited transaction between the two steps.

 

 

Revitalizer

 

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 8 of 8

franjavigarciavalencia
Enthusiast
Enthusiast

I can't believe I forgot to create at least one type on the family I was using for tests.

Thank you very much, it works perfectly now.

0 Likes