Does this code snippet help?
// Retrieve fabrication config for the selected service
FabricationConfiguration config
= FabricationConfiguration
.GetFabricationConfiguration( doc );
if( null == config )
{
message = "Unable to retrieve fabrication configuration";
return Result.Failed;
}
IList<FabricationService> services
= config.GetAllLoadedServices();
if( 0 == services.Count )
{
message = "No fabrication services found";
return Result.Failed;
}
FabricationService service = services
.FirstOrDefault( x => x.ServiceId.Equals( sid ) );
if( null == service )
{
message = string.Format(
"Unable to retrieve {0} fabrication service",
sname );
return Result.Failed;
}
List<FabricationServiceButton> hangerButtons
= new List<FabricationServiceButton>(
GetHangerButtons( service, 4 ) );
if( 0 == hangerButtons.Count )
{
message = string.Format(
"Unable to retrieve {0} fabrication service hanger buttons",
sname );
return Result.Failed;
}
hangerButtons.Sort( ( a, b )
=> string.Compare( a.Name, b.Name ) );
// For supply air, the hanger buttons listed are:
// button_names = "Rectangular Bearer, Flat Strap
// Hanger, Z Strap Hanger, Round Duct Hanger,
// Trapeze Hanger Round"
List<string> button_names = new List<string>(
hangerButtons.Select<FabricationServiceButton, string>(
b => b.Name ) );
string s = string.Join( ", ", button_names );
// Select which hanger to use
// Choose spacing, using default project length unit
// D = distance to end
// S = fixed spacing distance
// Attach to structural floors toggle on / off
// On selects structural by default
// If there's no structural element, attach to
// level above.
PlaceHangersUiForm form
= new PlaceHangersUiForm( button_names,
new RvtLengthValidator( doc ) );
NativeWindow nw = new NativeWindow();
nw.AssignHandle( uiapp.MainWindowHandle );
if( DialogResult.OK != form.ShowDialog( nw ) )
{
return Result.Cancelled;
}
FabricationServiceButton hanger_button
= hangerButtons[ form.ButtonIndex ];
Best regards,
Jeremy