Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KeyScheduleParameterName

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
paul
548 Views, 5 Replies

KeyScheduleParameterName

I'm trying to create an app that will remove the key element of a key schedule from doors but can't figure out how it works.

 

I get the KeyScheduleParameterName from the viewschedule of the key schedule but when I get the parameter from the door instance it doesn't show the key element of the key schedule, it shows some other element that has the name of the KeyScheduleParameterName. The odd thing is RevitLookUp is able to get the element ID for the key from the door.

 

Does anyone know if there are extra steps needed to get the key element ID?

5 REPLIES 5
Message 2 of 6
Joe.Ye
in reply to: paul

 

I don't think you can retrieve the Key element from the key schedule via API. The Key element doesn't have the category property. So we cannot recongnize them. 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 3 of 6
paul
in reply to: paul

So how is RevitLookUp able to do it?

Message 4 of 6
Joe.Ye
in reply to: paul

 

Hi Paul,

 

Yes, RevitLookup  finds the key element id by a door. In the RevitLookup, you can see the selected door's all parameters and its values, so you can see the key element id that assigned to this door.

 

Via API, you can  get that key element Id and also the key element itself that assigned to the door too. However, we cannot get other key elements listed in the owner key schedule. If the key element that you don't want to deleted is not assigned to a door, than you cannot get this key element.

 

To get key element id that assigned to a door, you just get the corresponding parameter value from the door, then get the element id. Here is the code fragment showing this process.

 

Parameter keyParameter = Element.get_Parameter("keyName");

ElementId id = keyParameter.AsElementId();

Element keyelem = doc.GetElement(id);  //Revit 2013.

 

Hope this explains.

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 5 of 6
paul
in reply to: Joe.Ye

That is what I'm trying to do with the following code:

 

FilteredElementCollector vcollector = new FilteredElementCollector(document);
FilteredElementCollector views = vcollector.OfClass((typeof(ViewSchedule)));
_keyParameters = new List<string>(views.Count());
foreach (ViewSchedule vs in views)
{
  if (vs.Definition.IsKeySchedule && (BuiltInCategory)vs.Definition.CategoryId.IntegerValue == BuiltInCategory.OST_Doors && !vs.IsTemplate)
  {
    _keyParameters.Add(vs.KeyScheduleParameterName);
  }
}

foreach (string parm in _keyParameters)
{
  Parameter p = _familyinstance.get_Parameter(parm);
  if(p.HasValue)
    do_something();
}

 

The problem is that Parameter p returns a parameter with the name of string parm but it isn't the key element and all doors return a parameter even if they have no key element assigned to them.

Message 6 of 6
Joe.Ye
in reply to: paul

 

The value stored the parameter you retrieved via these codes are ElementId. 

 

Parameter p = _familyinstance.get_Parameter(parm);
if(p.HasValue)

 

You need to get the key element Id by this line.

ElementId keyElemId = p.AsElementId();

 

And then get the key element by:

doc.GetElement(keyElementId)

 

For a door that you didn't assign its key parameter value, every door does have the key parameter, however the key parameter value should be empty for those had not been assigned key element.



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community