Making API for energy calculation, unable to "Set Parameters for certain walls to certain directions"

Making API for energy calculation, unable to "Set Parameters for certain walls to certain directions"

allazaruszcheong_21
Enthusiast Enthusiast
1,440 Views
23 Replies
Message 1 of 24

Making API for energy calculation, unable to "Set Parameters for certain walls to certain directions"

allazaruszcheong_21
Enthusiast
Enthusiast

Developing RevitAPI, calculating net energy transfer by a bulidng, it involves the directions of the walls, it works on a simple model, but not a more complicated real life model. Need help.


//Checking for SouthWest Facing Walls & Windows
bool isSouthWestFacing = IsSouthWestFacing(exteriorDirection);
if (isSouthWestFacing)
{
SouthWest_Wall_Lst.Add(WE);

inserts_0 = (WE as HostObject).FindInserts(true, true, true, true);

ParaSouthWestWall = WE.LookupParameter("SouthWest");
using (Transaction trans = new Transaction(doc, "ETTV_1"))
{
trans.Start();
ParaSouthWestWall.Set(1);

foreach (ElementId emtid in inserts_0)
{
Element emt = doc.GetElement(emtid);
emt.LookupParameter("SouthWest").Set(1);
}
trans.Commit();
}


}

the first error occurs when i try to set(1) the SpecialParameters "southwest" to a checkbox 



0 Likes
1,441 Views
23 Replies
Replies (23)
Message 2 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

allazaruszcheong_21_0-1698971756188.png


error message

0 Likes
Message 3 of 24

ctm_mka
Collaborator
Collaborator

I assume the parameter "SouthWest" is a custom parameter you assigned to the wall category? Is it a type or instance parameter? Your setting of a boolean value is correct, its how you are retrieving the parameter that is suspect. I believe error message means the parameter does not exist where you are looking for it.

0 Likes
Message 4 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

yes it is a custom parameter applied,  the thing is, the program works on a simple model but not a complicated real life building, so i believe the code works, but maybe there's a discrepancy in the more complicated version of the model? Either way i have not found a way to trouble shoot it. 

0 Likes
Message 5 of 24

RPTHOMAS108
Mentor
Mentor

This is odd behaviour but it likely relates to using LookupParameter which isn't ideal. I note that you have used a parameter with same name on the host object and on the inserts of that host object.

 

If your parameter is shared then reference it using its GUID, if it isn't then perhaps consider making it shared to do so. There may be something else going on but the code looks simple enough.

0 Likes
Message 6 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

Yes, "parameter with same name on the host object and on the inserts of that host object" on code and on Revit, they share the same parameter name. if that is what you mean, yes the parameter is shared if i am correct, i have a txt file named shared_parameters.txt, i will try using the GUID, but i have trouble accessing it and do not know how to.

0 Likes
Message 7 of 24

ctm_mka
Collaborator
Collaborator

Did some further testing. I'm guessing when you say "Simple model" it was not an actual wall object? I say this because walls are system families, and their parameters may need to be accessed differently. So here's a code example to access both instance and type parameters (shared or not is irrelevant) of a Wall object. Note the element needs to be dim'd as a Wall object first to get at the type parameter. 

Wall walltest = element as Wall;
string typevalue = walltest.WallType.LookupParameter("Name of Type Parameter").AsValueString();
string instancevalue = element.LookupParameter("Name of Instance Parameter").AsValueString();
               

 

0 Likes
Message 8 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

allazaruszcheong_21_0-1700194650840.png


In the real model, the walls are a "WallType", in the simple model, the walls are also a "WallType"

 

0 Likes
Message 9 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

This is my current error

allazaruszcheong_21_0-1700194913202.png

 

allazaruszcheong_21_1-1700194923806.png

 

0 Likes
Message 10 of 24

ctm_mka
Collaborator
Collaborator

so then, what is the code defining "room"?

0 Likes
Message 11 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

Hi, 

Sorry for the late replay, 

allazaruszcheong_21_0-1700243409044.png


It filters by OST_Rooms, is that fine?

0 Likes
Message 12 of 24

ctm_mka
Collaborator
Collaborator

so you are looking for a parameter from a room element and not a wall element? im confused.

0 Likes
Message 13 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

Sorry i should have been clearer,
The past groups working on this project assigned "Air-Conditioned" parameters to the rooms.

For the calculation to take place, it only involves the external walls of a building, no internal walls considered, as well as the rooms of those walls must be AC-Spaced in order to be used in the calculation.

So basically, -> find rooms that are AC-Spaced, then find the walls that are external, then get those walls' orientation. Any windows involved are also considered

0 Likes
Message 14 of 24

ctm_mka
Collaborator
Collaborator

Okay then, First, are you still having issue with reading the wall parameter? Second for the room, the solution is probably very similar, with a room being a system family.

0 Likes
Message 15 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

The issue with the walls suddenly went away, not sure what i did as i did not change the program nor revit model.
Also i noticed something, 

allazaruszcheong_21_0-1700244529259.png

 

allazaruszcheong_21_1-1700244538894.png


The first picture is a real life model,
The second picture is a sample model provided by my teacher.

I'm not sure but i feel like the room should be highlighted in the first picture? Maybe thats why its unable to detect it?

 

0 Likes
Message 16 of 24

ctm_mka
Collaborator
Collaborator

Thats really weird the wall issue just went away.  I'm not familiar with Rooms (we don't use them, not an architect) to know about the selection thing. For the parameter itself, I can only reiterate what I've said, depending on if its an instance or type parameter, affects how you access them with the LookupParameter method.

0 Likes
Message 17 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

I apologize its my first time learning RevitAPI and i am a complete newbie, my teacher just threw me this project along with 0 knowledge on C# and RevitAPI, i am completely struggling, will get back to you ASAP after i figure out what you mean

 

0 Likes
Message 18 of 24

ctm_mka
Collaborator
Collaborator

Ahhh okay, Then I definitely threw a bit much at you. The quick and dirty version of instance vs type parameters.  when you select an element, if you can see the parameter in the properties palette, it's an instance, and can usually be accessed with Element.LookupParameter. If you have to edit the elements type, it's a type parameter, and can usually be accessed with Element.Symbol.LookuParameter. Unless, of course, in your case where we are dealing with System families. Thats where the extra step of looking at the "WallType" (for walls) comes in.

0 Likes
Message 19 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

allazaruszcheong_21_0-1700246851988.pngallazaruszcheong_21_1-1700246863413.pngallazaruszcheong_21_2-1700246868741.png


This stuff is such a headache...

0 Likes
Message 20 of 24

allazaruszcheong_21
Enthusiast
Enthusiast

Okay, so i think i have to try to find out what type of variable i am trying to access and edit to make it a " " right? Its either an instance one or a Type parameter, i don't see the variable on the properties palette/tab so i think its a type parameter...

0 Likes