Shared parameter to schedulable field

Shared parameter to schedulable field

will.wydock
Advocate Advocate
775 Views
3 Replies
Message 1 of 4

Shared parameter to schedulable field

will.wydock
Advocate
Advocate

Hi,

 

Is it possible through the API to add columns to a schedule directly from a shared parameter files without creating a project parameter

 

I know that I can add Built in Parameters

ScheduleDefinition msd = mvs.Definition;
schedulableFields=msd.GetSchedulableFields();
ScheduleField mnamefield = msd.AddField(new SchedulableField(ScheduleFieldType.Instance, new ElementId(BuiltInParameter.ALL_MODEL_MARK)));

 

 

I know that I can search for specific text strings

 

IList<SchedulableField> schedulableFields = viewSched.Definition.GetSchedulableFields();

		SchedulableField field0 = schedulableFields.Where(sf => sf.GetName(doc) == "NameOfParameter").FirstOrDefault();
		ScheduleField scheduleField0 = viewSched.Definition.AddField(field0);

The idea would be to create the full version of the schedule possibly before the families with all the parameters have been added to the project.

 

0 Likes
776 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

Dear Wwydock,

 

Thank you for your query.

 

I cannot answer in full, lacking the required product knowledge.

 

What I can tell you:

 

  1. There is currently no API access to create project parameters.
  2. If you can achieve what you want through the user interface, it is probably possible programmatically as well (as long as you honour item 1).

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 4

will.wydock
Advocate
Advocate

Right now I am looking at Revit 2015-17 but am upgrading to 18. I am not looking to create a project parameter just add a shared parameter  to the a schedule as show as below and then eventually apply formatting and grouping.

Capture.PNG

0 Likes
Message 4 of 4

FAIR59
Advisor
Advisor

To add a shared parameter to a schedule:

 

SharedParameterElement shParamElem = SharedParameterElement.Lookup(document, paramGUID);
ScheduleField mnamefield = msd.AddField(new SchedulableField(ScheduleFieldType.Instance, shParamElem.Id));

So the question is, how do you get a SharedParameterElement into the document.

There are 2 possibilities:

  • loading a family that contains the shared parameter.
  • defining a project parameter.

Once the parameter is loaded into the document, you can delete the family or projectparameter (Binding) that you used to create the SharedParameterElement. The SharedParameterElement will remain in the document.

0 Likes