03-Revit API Programming - UI (User Interface)
03-Revit API Programming - UI (User Interface)
Revit UI API
Developer Technical Services
2014 Autodesk
Agenda
UI Topics
Ribbon
User Selection
Task dialog
Events
2014 Autodesk
Ribbon API
How to add your own Ribbon buttons
Ribbon API
Overview
Easy to use
Guidelines provided
2014 Autodesk
Push button
Pull-down button
Split button
Radio Group
Combo box
2014 Autodesk
RibbonPanel
RibbonItem
PushButton, PushButtonData
PulldownButton, PulldownButtonData
SplitButton, SplitButtonData
ComboBox, ComboBoxData
2014 Autodesk
Namespace
Autodesk.Revit.UI
Properties
2014 Autodesk
RibbonItem.Visible
RibbonItem.LongDescription
RibbonItem.ToolTipImage
PushButton.AvailabilityClassName
2014 Autodesk
User Selection
Point and object(s) selection using the API
User Selection
Overview
User Selection
Overview
StatusbarTip
View.SketchPlane
2014 Autodesk
User Selection
Selection Filter
ISelection Interface to help filter objects during selection
AllowElement()
AllowReference()
2014 Autodesk
Pick Sampler
2014 Autodesk
<CS>
XYZ pt1 = rvtUIDoc.Selection.PickPoint("Pick the first corner of walls");
XYZ pt2 = rvtUIDoc.Selection.PickPoint("Pick the second corner");
// simply create four walls with orthogonal rectangular profile
// from the two points picked.
List<Wall> walls = RevitIntroVB.ModelCreation.CreateWalls(
rvtUIDoc.Document, pt1, pt2);
// pick a wall to add a front door
SelectionFilterWall selFilterWall = new SelectionFilterWall();
Reference @ref = rvtUIDoc.Selection.PickObject(
ObjectType.Element, selFilterWall, "Select a wall to place a front door");
Wall wallFront = @ref.Element as Wall;
// add a door to the selected wall
RevitIntroVB.ModelCreation.AddDoor(rvtUIDoc.Document, wallFront);
</CS>
2014 Autodesk
Task Dialogs
Revit styled message boxes
Task Dialogs
Overview
Provide information
Ask a question
Allow users to select options to perform task
Task Dialog
Overview
Instance of Autodesk.Revit.UI.TaskDialog
instructions
detailed text
icons
buttons
command links
verification text, etc
2014 Autodesk
Dialog Sampler
<CS>
// (0) create an instance of task dialog to set more options.
TaskDialog myDialog = new TaskDialog("Revit UI Labs - Task Dialog Options");
// (1) set the main area. these appear at the upper portion of the dialog.
myDialog.MainIcon = TaskDialogIcon.TaskDialogIconWarning;
// or TaskDialogIcon.TaskDialogIconNone.
myDialog.MainInstruction =
"Main instruction: This is Revit UI Lab 3 Task Dialog";
myDialog.MainContent = "Main content: You can add detailed description here.";
if (stepByStep) myDialog.Show();
</CS>
2014 Autodesk
<CS>
TaskDialog houseDialog = new TaskDialog("Revit UI Labs - Create House Dialog");
houseDialog.MainInstruction = "Create a house";
houseDialog.MainContent = "There are two options to create a house.";
houseDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Interactive",
"You will pick two corners of rectangular footprint of a house, and choose where you
want to add a front door.");
houseDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "Automatic",
"This is will automatically place a house with a default settings.");
houseDialog.CommonButtons = TaskDialogCommonButtons.Cancel;
houseDialog.DefaultButton = TaskDialogResult.CommandLink1;
// show the dialog to the user.
TaskDialogResult res = houseDialog.Show();
</CS>
2014 Autodesk
Events
Overview
Types :
2014 Autodesk
Application level
Document level
Element level
Events
Overview
Document.IsModifiable
Document.IsReadOnly
RevitEventArgs.Cancellable
RevitAPIPreEventArgs.Cancel
2014 Autodesk
Events
// Do something here
}
Registering events
Unregistering events
return Result.Succeeded;
}
2014 Autodesk
Lab - Events
2014 Autodesk
2014 Autodesk
Updaters
Updaters :
Ability to implement a method that is informed of the scope of
changes
Implements the IUpdater interface.
GetUpdaterId ()
GetUpdaterName()
GetAdditionalInformation ()
GetChangePriority()
Execute()
2014 Autodesk
UpdaterRegistry.RegisterUpdater( updater );
Add Trigger
Change of Scope - list of ElementIds or list of elements via ElementFilter.
Change
of Type - addition, deletion and modification
// Set
the filter
ElementClassFilter filter = new ElementClassFilter( typeof( Wall ) );
// Add trigger
UpdaterRegistry.AddTrigger(updater.GetUpdaterId(),filter,
Element.GetChangeTypeGeometry());
2014 Autodesk
2014 Autodesk
Conclusion
Where do we go next
We have covered
UI Topics
Ribbon
User Selection
Task dialog
Events
Dynamic model update
2014 Autodesk
Learning More
http://www.autodesk.com/developrevit
Discussion Groups
http://www.autodesk.com/apitraining
http://thebuildingcoder.typepad.com
http://adndevblog.typepad.com/aec/
Developer Wiki
http://www.autodesk.com/revit-help/?guid=GUID-F0A122E0-E556-4D0D-9D0F-7E72A9315A42
http://www.autodesk.com/joinadn
http://adn.autodesk.com
2014 Autodesk
Thank you!
2014 Autodesk
Autodesk is a registered trademark of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and/or other countries. All other brand names,
product names, or trademarks belong to their respective holders. Autodesk reserves the right to alter product and services offerings, and specifications
and pricing at any time without notice, and is not responsible for typographical or graphical errors that may appear in this document.
2014 Autodesk, Inc. All rights reserved.