Clarification to my Question : I have a document called docSource. The document has all the built in parameters and we added a shared parameter to it. Now, I am trying to do transfer project standards, I am trying to copy/duplicate all walltypes to the target project which is my project. So, I am duplicating the wall types from docSource to docTarget. When I am copying all the parameters, only the particular shared parameter which we have added to docSource is not duplicating/Copying. Everything else is getting duplicated except the shared parameter we have added. I am using the below code.
public void TransferProjectStandards(ModelPath fileName, Document doc, Application App)
{
OpenOptions openOption = new OpenOptions();
openOption.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets;
Document docFamily = App.OpenDocumentFile(fileName, openOption);
FilteredElementCollector wallTypes = new FilteredElementCollector(docFamily).OfClass(typeof(WallType));
WallType wallType = null;
foreach (WallType wt in wallTypes)
{
wallType = wt;
if (!CheckWallTypeExists(wt, doc))
{
using (Transaction t = new Transaction(doc))
{
t.Start("Transfer Wall Type");
WallType newWallType = null;
FilteredElementCollector wallTypesProject = new FilteredElementCollector(doc).OfClass(typeof(WallType));
foreach (WallType wtcur in wallTypesProject)
{
if (wtcur.Kind == wallType.Kind)
{
newWallType = wtcur.Duplicate(wallType.Name) as WallType;
break;
}
}
Parameter p = null;
foreach (Parameter p1 in newWallType.Parameters)
{
Definition d = p1.Definition;
if (p1.IsReadOnly)
{
break;
}
else
{
p = wallType.get_Parameter(d);
if (null == p)
{
break;
}
else
{
if (p.StorageType == StorageType.ElementId)
{
break;
}
else
{
if (p.StorageType == StorageType.Double)
{
p1.Set(p.AsDouble());
}
else if (p.StorageType == StorageType.String)
{
p1.Set(p.AsString());
}
else if (p.StorageType == StorageType.Integer)
{
p1.Set(p.AsInteger());
}
}
}
}
}
t.Commit();
}
}
}
}