- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
with PromptForFamilyInstancePlacement does not show us component placement options. The code we are using is the following:
public Element FindElementByName(Document doc, Type targetType,string targetName)
{
FilteredElementCollector filtro = new FilteredElementCollector(doc);
FilteredElementCollector aux = filtro.OfClass(targetType);
return aux.FirstOrDefault<Element>(e => e.Name.Equals(targetName));
}
public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
ref string message,
ElementSet elements)
{
UIApplication app = revit.Application;
Document doc = app.ActiveUIDocument.Document;
UIDocument uidoc = app.ActiveUIDocument;
Family familia = FindElementByName(doc, typeof(Family), nombreFamilia.Replace(".rfa","")) as Family;
FamilySymbol symbol = null;
if (null == familia)
{
Transaction trans = new Transaction(revit.Application.ActiveUIDocument.Document, "Cargar familia");
trans.Start();
doc.LoadFamily(Path.Combine(ButtonIconsFolder, nombreFamilia), out familia);
trans.Commit();
}
foreach (ElementId id in familia.GetFamilySymbolIds())
{
symbol = familia.Document.GetElement(id) as FamilySymbol;
break;
}
uidoc.PromptForFamilyInstancePlacement(symbol);
return Autodesk.Revit.UI.Result.Succeeded;
}
We have also tried to do it with the CM command using the following function:
RevitCommandId idplace = RevitCommandId.LookupPostableCommandId(PostableCommand.PlaceAComponent);
if (idplace != null) { app.PostCommand(idplace); }
This function does show us the component placement options, but it does not allow us to indicate the family to load, so by default it always uses the last one loaded.
We are looking for an intermediate solution, something that allows us to indicate the family to load and also shows us the component placement options.
Solved! Go to Solution.