public bool BindSharedParameters()
{
if (File.Exists(m_sharedFilePath) &&
null == m_sharedFile)
{
MessageBox.Show("SharedParameter.txt has an invalid format.");
return false;
}
foreach (DefinitionGroup group in m_sharedFile.Groups)
{
foreach (ExternalDefinition def in group.Definitions)
{
// check whether the parameter already exists in the document
FamilyParameter param = m_manager.get_Parameter(def.Name);
if (null != param)
{
continue;
}
BuiltInParameterGroup bpg = BuiltInParameterGroup.INVALID;
try
{
if (def.OwnerGroup.Name == "Dimensions")
{
bpg = BuiltInParameterGroup.PG_GEOMETRY;
}
else if (def.OwnerGroup.Name == "Graphics")
{
bpg = BuiltInParameterGroup.PG_GRAPHICS;
}
else if (def.OwnerGroup.Name == "Model Properties")
{
bpg = BuiltInParameterGroup.PG_ADSK_MODEL_PROPERTIES;
}
else if (def.OwnerGroup.Name == "Overall Legend")
{
bpg = BuiltInParameterGroup.PG_OVERALL_LEGEND;
}
else if (def.OwnerGroup.Name == "Electrical")
{
bpg = BuiltInParameterGroup.PG_ELECTRICAL;
}
else if (def.OwnerGroup.Name == "Mechanical")
{
bpg = BuiltInParameterGroup.PG_MECHANICAL;
}
else if (def.OwnerGroup.Name == "Electrical - Lighting")
{
bpg = BuiltInParameterGroup.PG_ELECTRICAL_LIGHTING;
}
else if (def.OwnerGroup.Name == "Identity Data")
{
bpg = BuiltInParameterGroup.PG_IDENTITY_DATA;
}
else if (def.OwnerGroup.Name == "Data")
{
bpg = BuiltInParameterGroup.PG_DATA;
}
else if (def.OwnerGroup.Name == "Electrical - Loads")
{
bpg = BuiltInParameterGroup.PG_ELECTRICAL_LOADS;
}
else if (def.OwnerGroup.Name == "Mechanical - Air Flow")
{
bpg = BuiltInParameterGroup.PG_MECHANICAL_AIRFLOW;
}
else if (def.OwnerGroup.Name == "Energy Analysis")
{
bpg = BuiltInParameterGroup.PG_ENERGY_ANALYSIS;
}
else if (def.OwnerGroup.Name == "Photometrics")
{
bpg = BuiltInParameterGroup.PG_LIGHT_PHOTOMETRICS;
}
else if (def.OwnerGroup.Name == "Mechanical - Loads")
{
bpg = BuiltInParameterGroup.PG_MECHANICAL_LOADS;
}
else if (def.OwnerGroup.Name == "Structural")
{
bpg = BuiltInParameterGroup.PG_STRUCTURAL;
}
else if (def.OwnerGroup.Name == "Plumbing")
{
bpg = BuiltInParameterGroup.PG_PLUMBING;
}
else if (def.OwnerGroup.Name == "Green Building Properties")
{
bpg = BuiltInParameterGroup.PG_GREEN_BUILDING;
}
else if (def.OwnerGroup.Name == "Materials and Finishes")
{
bpg = BuiltInParameterGroup.PG_MATERIALS;
}
else if (def.OwnerGroup.Name == "Other")
{
bpg = BuiltInParameterGroup.INVALID;
}
else if (def.OwnerGroup.Name == "Construction")
{
bpg = BuiltInParameterGroup.PG_CONSTRUCTION;
}
else if (def.OwnerGroup.Name == "Phasing")
{
bpg = BuiltInParameterGroup.PG_PHASING;
}
else
{
bpg = BuiltInParameterGroup.INVALID;
}
m_manager.AddParameter(def, bpg, false);
}
catch (System.Exception e)
{
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
}
return true;
}