Revit API

Reply
Contributor
paul
Posts: 24
Registered: ‎10-09-2004
Message 1 of 6 (244 Views)
Accepted Solution

KeyScheduleParameterName

244 Views, 5 Replies
08-31-2012 12:20 PM

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?

ADN Support Specialist
Joe.Ye
Posts: 324
Registered: ‎03-05-2010
Message 2 of 6 (223 Views)

Re: KeyScheduleParameterName

09-06-2012 02:04 AM 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
Contributor
paul
Posts: 24
Registered: ‎10-09-2004
Message 3 of 6 (219 Views)

Re: KeyScheduleParameterName

09-06-2012 10:26 AM in reply to: paul

So how is RevitLookUp able to do it?

ADN Support Specialist
Joe.Ye
Posts: 324
Registered: ‎03-05-2010
Message 4 of 6 (213 Views)

Re: KeyScheduleParameterName

09-06-2012 08:16 PM 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
Contributor
paul
Posts: 24
Registered: ‎10-09-2004
Message 5 of 6 (204 Views)

Re: KeyScheduleParameterName

09-07-2012 11:28 AM 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.

ADN Support Specialist
Joe.Ye
Posts: 324
Registered: ‎03-05-2010
Message 6 of 6 (187 Views)

Re: KeyScheduleParameterName

09-12-2012 02:23 AM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Revit

Twitter

Facebook

Blogs

Youtube