Lets face it New Autodesk Revit 2013 UI
- Slides: 45
Let's face it: New Autodesk Revit 2013 UI API Functionality Jeremy Tammik Principal Developer Consultant © 2012 Autodesk
About the Presenter Jeremy Tammik Principal Developer Consultant Developer Technical Services EMEA, Autodesk SARL Jeremy is a member of the AEC workgroup of the Autodesk Developer Network ADN team, providing developer support, training, conference presentations, and blogging on the Revit API. He joined Autodesk in 1988 as the technology evangelist responsible for European developer support to lecture, consult, and support Auto. CAD application developers in Europe, the U. S. , Australia, and Africa. He was a co-founder of ADGE, the Auto. CAD Developer Group Europe, and a prolific author on Auto. CAD application development. He left Autodesk in 1994 to work as an HVAC application developer, and then rejoined the company in 2005. Jeremy graduated in mathematics and physics in Germany, worked as a teacher and translator, then as a C++ programmer on early GUI and multitasking projects. He is fluent in six European languages, vegetarian, has four kids, plays the flute, likes reading, travelling, theatre improvisation, yoga, carpentry, loves mountains, oceans, sports, dancing, and especially climbing. © 2012 Autodesk
Class Summary § § Revit 2013 API add-in integration functionality Continue Saikat's Revit UI API snapshot CP 3272 which covers § § Look in more depth at § § § § Control of disciplines and add-in availability Commands, keyboard shortcuts and the quick access toolbar Replacing an existing Revit command Document management and View API Progress bar notifications Options dialogue WPF custom extensions Embedding and controlling a Revit view UIView and Windows device coordinates Drag and drop Prerequisites § . NET programming and Revit API basics © 2012 Autodesk
Learning Objectives In depth understanding of Revit API add-in integration Add-in interaction using the new document management, view creation, settings, progress bar notification, WPF option dialogue extension, preview control, UIView and Windows coordinates, drag and drop, etc. § Add-in alignment with the Revit user interface look and feel § Know, understand reuse Revit SDK and custom AU sample code § § © 2012 Autodesk
Agenda § § § Document management and View API Revit progress bar notifications Options dialogue WPF custom extensions Embedding and controlling a Revit view Drag and drop UIView © 2012 Autodesk
Introduction © 2012 Autodesk
Autodesk Developer Network www. autodesk. com/adnopen www. autodesk. com/joinadn § Access to almost all Autodesk software and SDK’s § § Product direction through conferences Unlimited technical support API training classes § § Includes early access to beta software One to three for professional members Marketing benefits § § Exposure on autodesk. com Promotional opportunities © 2012 Autodesk
Acronyms § § § ADN AEC API BIM GUI HVAC MEP RAC RME RST SDK UI Autodesk Developer Network Architecture, Engineering, Construction Application Programming Interface Building Information Model Graphical User Interface Heating, Ventilation, and Air Conditioning Mechanical, Electrical, and Plumbing Revit Architecture Revit MEP Revit Structure Software Development Kit User Interface © 2012 Autodesk
Sample Applications § Minimal simplified AU sample commands Revit. Ui. Api. News § § § Win. Coords § § UIView, Windows device coordinates, own tooltip Progress. Notifier SDK sample § § Cmd. Add. Options. Tab Cmd. Drag. Drop. Api Cmd. Preview. Control. Simple Cmd. Progress. Watcher Cmd. Ui. View Subscribe to progress bar events UIAPI SDK sample § § § Add customised tabs to Options dialogue Revit preview control Drag and drop © 2012 Autodesk
Document Management and View API © 2012 Autodesk
Document Management and View API § § § Open. And. Activate. Document enables opening a project file UIDocument. Active. View enables view change within document UIView class provides access to UI views § § § Get. Open. UIViews lists all open views for a UI document Window location and Windows device coordinates View settings and creation © 2012 Autodesk
View Settings § View properties to read and write detail level, discipline, display style View. Detail. Level: coarse, medium, fine, etc. View. Discipline: architectural, coordination, electrical, mechanical, plumbing, structural § Display. Style: Wireframe, HLR, Shading. With. Edges, Rendering, Realistic , Flat. Colors, Realistic. With. Edges, Raytrace § § © 2012 Autodesk
View Creation § View creation § § § Static Create methods on all View classes Schedule, plan, 3 D isometric and perspective Specify view family type element id © 2012 Autodesk
Progress Bar Notifications © 2012 Autodesk
Progress Bar Notifications § § Subscribe to Progress. Changed event Event handler receives Progress. Changed. Event. Args Caption – progress bar caption describing operation in progress Stage – current stage of the progress bar § Started, Caption. Changed, Range. Changed, Position. Changed, User. Cancelled, Finished § Lower. Range – lower limit of range, always zero § Upper. Range – upper limit of range, any non-zero number § Position – value in [0, Upper. Range] incremented with 'Position. Changed' stage § § © 2012 Autodesk
Progress. Watcher AU Sample public Result Execute( External. Command. Data command. Data, ref string message, Element. Set elements ) { UIApplication uiapp = command. Data. Application; Application app = uiapp. Application; app. Progress. Changed += new Event. Handler<Progress. Changed. Event. Args>( On. Progress. Changed ); return Result. Succeeded; } void On. Progress. Changed( object sender, Progress. Changed. Event. Args e ) { double percent = 100. 0 * e. Position / e. Upper. Range; Debug. Print( "'{0}' stage {1} position {2} [{3}, {4}] ({5}%)", e. Caption, e. Stage, e. Position, e. Lower. Range, e. Upper. Range, percent. To. String( "0. ##" ) ); } © 2012 Autodesk
Sample Notifications Opening a Project ' ' stage 'Drawing: 'Drawing: 'Drawing: 'Drawing: 'Drawing: 'Drawing: 'Drawing: 'Drawing: 'Drawing: ' ' stage ' ' stage 'Drawing: 'Drawing: 'Drawing: 'Drawing: Finished position 0 [0, 2147483647] (0%) floor_slab. rvt - 3 D View: {3 D}' stage Started position 0 [0, 100] (0%) floor_slab. rvt - 3 D View: {3 D}' stage Position. Changed position 0 [0, 100] (0%) floor_slab. rvt - 3 D View: {3 D}' stage Position. Changed position 50 [0, 100] (50%) floor_slab. rvt - 3 D View: {3 D}' stage Position. Changed position 75 [0, 100] (75%) floor_slab. rvt - 3 D View: {3 D}' stage Finished position 75 [0, 100] (75%) floor_slab. rvt - 3 D View: {3 D}' stage Started position 0 [0, 100] (0%) floor_slab. rvt - 3 D View: {3 D}' stage Position. Changed position 0 [0, 100] (0%) floor_slab. rvt - 3 D View: {3 D}' stage Position. Changed position 25 [0, 100] (25%) floor_slab. rvt - 3 D View: {3 D}' stage Finished position 25 [0, 100] (25%) Started position 0 [0, 2147483647] (0%) Finished position 0 [0, 2147483647] (0%) floor_slab. rvt - 3 D View: {3 D}' stage Started position 0 [0, 100] (0%) floor_slab. rvt - 3 D View: {3 D}' stage Position. Changed position 0 [0, 100] (0%) floor_slab. rvt - 3 D View: {3 D}' stage Position. Changed position 25 [0, 100] (25%) floor_slab. rvt - 3 D View: {3 D}' stage Finished position 25 [0, 100] (25%) © 2012 Autodesk
Progress. Notifier SDK Sample § Display progress information in a stack data structure § § Subscribe to the Progress. Changed event Access Progress. Changed. Event. Args handler argument properties Manage a stack of subtransaction progress information Add-Ins > Rvt. Samples > Basics > Progress. Notifier > Open Document © 2012 Autodesk
Options Dialogue WPF Extensions © 2012 Autodesk
Options dialogue WPF custom extensions § § § Subscribe to UIApplication Displaying. Options. Dialog event Event handler receives Displaying. Options. Dialog. Event. Args Pages. Count property § § Number of Options dialogue tabs including default Revit ones Add. Tab method § Add a tab with tab name and handler information provided by Tabbed. Dialog. Extension class instance © 2012 Autodesk
Tabbed. Dialog. Extension Class § Constructor takes two arguments § § Methods to get and set contextual help Properties to read § § § WPF user control instance and OK handler These cannot be changed Control – the control On. OKAction – the ok handler Properties to get and set § § On. Cancel. Action – the cancel handler On. Restore. Defaults. Action – the restore defaults handler © 2012 Autodesk
AU Sample Custom Tab public partial class User. Control 1 : User. Control { string _name; public User. Control 1( string name ) { _name = name; public Result Execute( External. Command. Data command. Data, ref string message, Element. Set elements ) { UIApplication uiapp = command. Data. Application; Initialize. Component(); } private void button 1_Click( object sender, Routed. Event. Args e ) { Task. Dialog. Show( _name, "I was clicked. . . " ); } public void On. OK() { Task. Dialog. Show( _name, "OK" ); } uiapp. Displaying. Options. Dialog += new Event. Handler< Displaying. Options. Dialog. Event. Args>( On. Displaying. Options. Dialog ); return Result. Succeeded; } void On. Displaying. Options. Dialog( object sender, Displaying. Options. Dialog. Event. Args e ) { User. Control 1 c = new User. Control 1( "Dev. Camp User Control" ); public void On. Cancel() { Task. Dialog. Show( _name, "On. Cancel" ); } e. Add. Tab( "Dev. Camp Custom Tab", new Tabbed. Dialog. Extension( c, c. On. OK ) ); } public void On. Restore. Defaults() { Task. Dialog. Show( _name, "On. Restore. Defaults" ); } } © 2012 Autodesk
Additional References Required § § Presentation. Core Presentation. Framework System. Xaml Windows. Base © 2012 Autodesk
Revit SDK UIAPI Sample © 2012 Autodesk
Preview Control © 2012 Autodesk
Embed and control a Revit view § § § § Preview. Control Class Enable browsing the Revit model Input document and view id Form or window host must be modal View can be any graphical view, i. e. printable View can be manipulated by view cube Visibility and graphical settings are effective © 2012 Autodesk
Using a Revit preview control § § Create a standard. NET form Insert WPF host System. Windows. Forms. Integration. Element. Host § Populate with Revit preview control element. Host. Child = new Preview. Control( doc, view. Id ); § Dispose after use Preview. Control vc = element. Host. Child as Preview. Control; if( vc != null ) { vc. Dispose(); } © 2012 Autodesk
Determine Printable Views IEnumerable<View> views = new Filtered. Element. Collector( doc ). Of. Class( typeof( View ) ). Cast<View>(). Where<View>( v => v. Can. Be. Printed ); © 2012 Autodesk
AU Sample Preview. Control. Simple using( Preview. Control pc = new Preview. Control( doc, view. Id ) ) { #if CREATE_FORM_BY_CODE using( System. Windows. Form form = new System. Windows. Form() ) { Element. Host element. Host = new Element. Host(); element. Host. Location = new System. Drawing. Point( 0, 0 ); using( Transaction tx = new Transaction( doc ) ) { tx. Start( "Display Simple Revit Preview" ); View view = doc. Active. View; Display. Revit. View( doc, view, revit_window ); tx. Commit(); } element. Host. Dock = Dock. Style. Fill; element. Host. Tab. Index = 0; element. Host. Parent = form; element. Host. Child = pc; form. Text = _caption_prefix + view. Name; form. Controls. Add( element. Host ); form. Size = new Size( 400, 400 ); form. Show. Dialog( owner ); } #else // if not CREATE_FORM_BY_CODE Form 1 form = new Form 1( pc ); form. Show. Dialog( owner ); #endif // CREATE_FORM_BY_CODE } © 2012 Autodesk
Revit SDK UIAPI Preview. Control Sample © 2012 Autodesk
Drag and Drop © 2012 Autodesk
Drag and Drop API § § Two overloads of new static UIApplication Do. Drag. Drop method Do. Drag. Drop( ICollection<string> ) § § § Do. Drag. Drop( object, IDrop. Handler ) § § Initiate standard built-in Revit drag and drop operation Collection of file names Initiate drag and drop operation with a custom drop implementation Designed for use in a modeless form § The one and only Revit API method not requiring valid Revit API context © 2012 Autodesk
Drag and Drop a List of Files § One Auto. CAD format or image file § § More than one Auto. CAD format or image files § § All the families are loaded More than one family file including other format files § § § The family is loaded, and an editor started to place an instance More than one family file § § A new import placement editor is started for the first file One family file § § A new import placement editor is started to import the file Revit tries to open all the files Valid file or list of files: Revit uses them appropriately Any files are not usable: Failure is signalled to user, no exception is thrown, add-in is notified © 2012 Autodesk
Initiating Standard Drag and Drop private void list. Box 1_Mouse. Move( object sender, Mouse. Event. Args e ) { if( System. Windows. Forms. Control. Mouse. Buttons == Mouse. Buttons. Left ) { Family. List. Box. Member member = (Family. List. Box. Member) list. Box 1. Selected. Item; // Use standard Revit drag and drop behavior List<String> data = new List<String>(); data. Add( member. Full. Path ); UIApplication. Do. Drag. Drop( data ); } } © 2012 Autodesk
AU Custom Drag and Drop Handler public class Loaded. Family. Drop. Handler : IDrop. Handler { public void Execute( UIDocument uidoc, object data ) { Element. Id family. Symbol. Id = (Element. Id) data; Family. Symbol symbol = uidoc. Document. Get. Element( family. Symbol. Id ) as Family. Symbol; if( symbol != null ) { uidoc. Prompt. For. Family. Instance. Placement( symbol ); } private void list. View_Mouse. Move( object sender, Mouse. Event. Args e ) { if( Control. Mouse. Buttons == Mouse. Buttons. Left ) { List. View. Item selected. Item = list. View 1. Selected. Items. Cast<List. View. Item>(). First. Or. Default<List. View. Item>(); if( selected. Item != null ) { Loaded. Family. Drop. Handler myhandler = new Loaded. Family. Drop. Handler(); } } UIApplication. Do. Drag. Drop( selected. Item. Tag, myhandler ); } } } © 2012 Autodesk
AU Drag and Drop Sample © 2012 Autodesk
UIView and Windows Coordinates © 2012 Autodesk
UIView Methods § Get. Window. Rectangle § § Get. Zoom. Corners § § Return view drawing area rectangle Windows device coordinates Return view rectangle Revit model coordinates Zoom. And. Center. Rectangle § Zoom and centre view to a specified rectangle © 2012 Autodesk
UIView Sample Command § § § Get the active view Get all UIView instances Determine the UIView for the active view Query and report its Windows and Revit coordinates Calculate new Revit coordinates to zoom in by 10% Call Zoom. And. Center. Rectangle to do so © 2012 Autodesk
UIView Sample Code View view = doc. Active. View; UIView uiview = null; IList<UIView> uiviews = uidoc. Get. Open. UIViews(); foreach( UIView uv in uiviews ) { if( uv. View. Id. Equals( view. Id ) ) { uiview = uv; break; } } Rectangle rect = uiview. Get. Window. Rectangle(); IList<XYZ> corners = uiview. Get. Zoom. Corners(); XYZ p = corners[0]; XYZ q = corners[1]; XYZ v = q - p; XYZ center = p + 0. 5 * v; v *= 0. 45; p = center - v; q = center + v; uiview. Zoom. And. Center. Rectangle( p, q ); © 2012 Autodesk
Summary and Further Reading © 2012 Autodesk
Class Summary § § § Revit 2013 API add-in integration functionality Continuation of Saikat's Revit UI API snapshot CP 3272 We looked in more depth at § § Revit progress bar notifications Options dialogue WPF custom extensions Embed and control a Revit view Drag and drop © 2012 Autodesk
Materials § Sample Code § § Progress. Watcher Add. Options. Tab Preview. Control. Simple Drag. Drop. Api © 2012 Autodesk
Learning More § Revit Developer Center: Dev. TV introduction, SDK, Samples, API Help § § Developer Guide and Online Help § § http: //thebuildingcoder. typepad. com ADN, The Autodesk Developer Network § § http: //adndevblog. typepad. com/AEC The Building Coder, Jeremy Tammik's Revit API Blog § § http: //www. autodesk. com/apitraining ADN AEC Dev. Blog § § http: //discussion. autodesk. com > Revit Architecture > Revit API Training Classes § § http: //www. adskconsulting. com/adn/cs/api_course_sched. php > Revit API Discussion Group § § http: //www. autodesk. com/revitapi-wikihelp Revit API Webcasts and Trainings § § http: //www. autodesk. com/developrevit http: //www. autodesk. com/joinadn and http: //www. autodesk. com/adnopen Dev. Help Online for ADN members § http: //adn. autodesk. com © 2012 Autodesk
Autodesk, Auto. CAD* [*if/when mentioned in the pertinent material, followed by an alphabetical list of all other trademarks mentioned in the material] are registered trademarks or trademarks 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. © 2012 Autodesk, Inc. All rights reserved. © 2012 Autodesk
- Systemlinje
- Revit built in parameter
- Revit nomenclature
- Revit app exchange
- User interface revit
- Revit family creation
- Newforma plans app
- Revit model
- Showcase revit
- Subtractive modeling revit
- Revit live 2018
- Amphitheatre revit model
- Positive face and negative face examples
- Brown and levinson
- Hospice face to face template
- 2 elements of communication
- Face to face interview pros and cons
- Kiran sanghera
- I have a flat face
- Onomatopoeia in romeo and juliet act 1
- Cis face and trans face
- Face to face class
- Corso ecdl
- Autodesk mapguide viewer
- Autodesk inventor 2008
- Autodesk building systems
- Productstream autodesk
- Certiport organización principal
- Aud autodesk
- Scad to fusion 360
- Autodesk
- Autodesk inventor
- Autodesk direct
- Autodesk maya 2009
- Constantin stancescu
- Edificios en autocad
- Autodesk
- Inventor 11
- Autodesk inventor 10
- Autodesk maya 2011
- Autodesk matchmover
- Autodesk circuits
- Autodesk sketchbook wood texture
- Autodesk inventor interface
- Time the new face of america
- Paper that lets the light shine through