- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Everyone,
I am looking to access a specific instance parameter of a family instance placed with a custom C# command. Below is the code that loads the family and then places it as a family symbol.
private static FamilySymbol LoadFamilySymbol(string path, string famName)
{
FamilySymbol famSymbol = null;
Family fam = null;
WsprFamilyLoadOptions loadOptions = new WsprFamilyLoadOptions();
Transaction t = new Transaction(ndoc, "T1");
t.Start();
ndoc.LoadFamilySymbol(path, famName, (IFamilyLoadOptions)(object)loadOptions, out famSymbol);
famSymbol.Activate();
t.Commit();
return famSymbol;
}
public static FamilySymbol FamilySymbolPlacement(Document doc, UIDocument uidoc, string FamilyName, byte[] Family)
{
String path = string.Format("C:\\temp\\{0}.rfa", FamilyName);
File.WriteAllBytes(path, Family);
FamilySymbol familySymbol = null;
try
{
familySymbol = LoadFamilies.LoadFamilySymbol(path, FamilyName);
PromptForFamilyInstancePlacementOptions famoptions = null;
if (familySymbol != null)
{
try
{
if (famoptions == null)
{
uidoc.PromptForFamilyInstancePlacement(familySymbol);
}
else
{
uidoc.PromptForFamilyInstancePlacement(familySymbol, famoptions);
}
}
catch (RvtExceptions.OperationCanceledException val)
{
ProjectData.SetProjectError((Exception)val);
RvtExceptions.OperationCanceledException ex3 = val;
ProjectData.ClearProjectError();
}
}
}
catch (RvtExceptions.InvalidOperationException val2)
{
ProjectData.SetProjectError((Exception)val2);
RvtExceptions.InvalidOperationException ex2 = val2;
ProjectData.ClearProjectError();
}
return familySymbol;
Below are a few way I have tried to access the instance parameter of the family symbol.
1.
FamilySymbol fsym = PlaceFamilies.PlaceFamilySymbol(FamilyNames.BreakLine_Normal, Resources.Break_Line_Normal, uidoc, doc);
Element e = fsym;
Parameter test = e.ParametersMap.get_Item("Drawing Scale");
2.
Parameter param2 = e.LookupParameter("Drawing Scale");
3.
Element e = fsym;
foreach(Parameter p in e.ParametersMap)
{
Debug.Print(p.Definition.Name);
string s = p.Definition.Name;
}
I have been unable to access instance parameter "Drawing Scale" with any of the above methods.
Upon checking with Revit Lookup, Element e in above code returns the id of the family instead of family instance, how can I access the family instance?
Just to clarify it further, the newly placed family instance does have parameter "Drawing Scale" in the properties panel.
Found the below link for setting parameter values but this used FamilyManager which can only run in a Family document, my command is meant to run in the project document.
https://thebuildingcoder.typepad.com/blog/2011/11/set-family-parameter-requires-type.html
Checked below post on the forum which highlights that a transaction needs to be started for placement and parameters to be accessed within the transaction, but PromptForFamilyInstancePlacement starts its own transaction and does not allow to be run within another transaction.
Would be great if anyone is able to provide any guidance towards accessing and modifying the instance parameter of the family symbol.
Thank you
Solved! Go to Solution.