• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Revit API

    Reply
    Member
    Posts: 3
    Registered: ‎01-20-2010

    Create.NewView3D (Revit 2013)

    596 Views, 6 Replies
    05-03-2012 03:23 AM

    I'm migrating from version 2012 to 2013.

    Can anybody help me 'translating' the next line?

     

    generatedView = m_Document.Create.NewView3D(new Autodesk.Revit.DB.XYZ(0, 0, 1));

     

     

    Thanks,

    Harry

    Please use plain text.
    Distinguished Contributor
    ollikat
    Posts: 104
    Registered: ‎04-01-2011

    Re: Create.NewView3D (Revit 2013)

    05-06-2012 10:02 PM in reply to: AutoHarry

    According to API documentation, you should use View3D::CreateIsometric() method instead. It shouldn't be difficult...just get a suitable view type. Or is there something specifically unclear about this...?

    Please use plain text.
    Member
    Posts: 3
    Registered: ‎01-20-2010

    Re: Create.NewView3D (Revit 2013)

    05-07-2012 02:47 AM in reply to: AutoHarry

    The problem is I don't know how to get 'a suitable view type'....

    I tried to use 'ViewOrientation3D' but could find an easy solution.

     

    Please use plain text.
    ADN Support Specialist
    Posts: 180
    Registered: ‎03-05-2010

    Re: Create.NewView3D (Revit 2013)

    05-10-2012 02:56 AM in reply to: AutoHarry

     

    In Revit 2013, there is a new class ViewFamilyType, it represents the view type. This class derives from Element class. You can use the FilteredElementCollector to find the object set. Then get one of the view type.



    Joe Ye
    Developer Technical Services
    Autodesk Developer Network
    Please use plain text.
    New Member
    Posts: 2
    Registered: ‎12-11-2009

    Re: Create.NewView3D (Revit 2013)

    05-20-2012 05:36 AM in reply to: Joe.Ye

    But getting a viewtype this way is going to copy an existing view. What NewView3D was doing was allowing one create a new view with a different direction.

     

    In my mind there is also confusion between specifying a type and the elementid of an existing view.

    Please use plain text.
    Distinguished Contributor
    Posts: 120
    Registered: ‎01-06-2003

    Re: Create.NewView3D (Revit 2013)

    06-10-2012 01:42 AM in reply to: PeterLMann

    Did you find a sample for this? I am facing the same, and finding it tricky. A single line example to replace the deprecated code would be invaluable. Thanks, Dale 

    Please use plain text.
    New Member
    Posts: 2
    Registered: ‎12-11-2009

    Re: Create.NewView3D (Revit 2013)

    06-10-2012 09:09 AM in reply to: PeterLMann
    Hi Dale, I haven't found a complete solution to this, but enough to do what I needed, which was a temporary view to find the centroid of a family via it's bounding box. I have attached a solution Jeremy provided. Best regards Peter _____ Peter L Mann RIBA FIAP CodeBook International Ltd. St Clere, 15 Deepdene Wood, Dorking, RH5 4BG, UKwww.CodeBookInternational.com tel: +44 1306 877 513 mobile: +44 7979 805 609 _____Description: Autodesk, Inc.Developer Network Dear Peter, Thank you for your query. I have not updated the blog post you mention yet, nor explored in detail how to do so. Just looking at the description and sample provided with the CreateIsometric method by the Revit API help file RevitAPI.chm, though, it looks as if it should be pretty straightforward. Please look at the description of the View3D class in the help file. It includes some sample code implementing a Getinfo_View3D method, which points to some useful methods on the class. Oops, I was just going to suggest using the EyePosition property to define the camera position, only to notice that that is marked obsolete as well. Well, that leaves the ViewDirection and Origin properties returning the direction towards the viewer and the origin of the screen... oops, both read-only. Ah, interestinger and interestinger ... look at the new View3D methods * SetOrientation: Sets the temporary orientation of the View3D. The new orientation is not saved in the document. * SaveOrientation: Converts the temporary orientation of the View3D into its saved orientation. They both make us of the new ViewOrientation3D class. Oh no, you should know this, and so should I: for every single migration question you ever have, please first of all take a look at the Revit API help file What's New section. It clearly and succinctly states: View API View Creation 1. Plan Views can now be created with the new ViewPlan.Create(document, viewFamilyTypeId, levelId) method. For example, a ceiling plan can be created as follows: Level level = null; ElementId viewFamily3d = ElementId.InvalidElementId; IEnumerable viewFamilyTypes = from elem in new FilteredElementCollector( doc ) .OfClass( typeof( ViewFamilyType ) ) let type = elem as ViewFamilyType where type.ViewFamily == ViewFamily.CeilingPlan select type; ViewPlan ceilingPlan = ViewPlan.Create( doc, viewFamilyTypes.First().Id, level.Id ); ceilingPlan.Name = "New Ceiling Plan for " + level.Name; ceilingPlan.DetailLevel = ViewDetailLevel.Fine; // 3D views can be created with // View3D.CreateIsometric and // View3D.CreatePerspective. // The new ViewOrientation3D object is used to // get or set the orientation of 3D views. View3D view = View3D.CreateIsometric( doc, viewFamily3d ); XYZ eyePosition = new XYZ( 10, 10, 10 ); XYZ upDirection = new XYZ( -1, 0, 1 ); XYZ forwardDirection = new XYZ( 1, 0, 1 ); view.SetOrientation( new ViewOrientation3D( eyePosition, upDirection, forwardDirection ) ); 2. The ViewSection class now has methods that support the creation of Callout, Reference Callout, and Reference Section views. 3. Rendering views containing images imported from disk can be created using the new ImageView class and the ImageView.Create method. The most interesting part of this for your case is the second part of the comment in the sample code. I hope this helps. Please let me know what you end up with, and I might have a look at migrating The Building Coder sample code as well. Thank you! Best regards, Jeremy Tammik Developer Technical Services http://adn.autodesk.com _____ Come to DevCamps this Summer; AEC DevCamp, June 6-7 and/or MFG DevCamp, June 13-14 where beginner and expert software developers learn face to face from Autodesk software engineers. New this year Cloud and Mobile app development classes! View detailed agenda and register here _____ At anytime, you may add information to your Case by simply replying to this email. Be sure to include this email in your reply, so that your comments are automatically updated in your Case. _____ If this is urgent, you have any questions or need further assistance, please contact one of the managers below: * Americas - Mikako Harada * Europe - Gary Wassell * South Asia - Virupaksha Aithal * China - Joe Ye * Japan - Katsuaki Takamizawa * Media & Entertainment - Cyrille Fauvel * Worldwide - Stephen Preston CaseNo:07269677. Case Description NewView3D is now obselete and the suggestion is to use CreateIsometric, but the arguments for this are document and view type, there isn't an option to specify a direction. How can I create a 3D view of a specified direction? I need this for a function based on one of Jeremy's tips. Public Function FindElemCentreXYZ(elem As Revit.DB.Element, ByRef max As Revit.DB.XYZ, ByRef min As Revit.DB.XYZ) As Revit.DB.XYZ ' based on http://thebuildingcoder.typepad.com/blog/2010/01/spot-elevation-creation-on- top-of-beam.html Try rTrans.DoStartSubTran() Dim centerOfBox = New Revit.DB.XYZ(0, 0, 0) Dim doc As Document = elem.Document Dim viewDirection As Revit.DB.XYZ = New Revit.DB.XYZ(0, 0, -1) Dim view3D As View3D = doc.Create.NewView3D(viewDirection) 'Dim VT As ElementId = Get3DViewElementID() 'Dim view3D As View3D = DB.View3D.CreateIsometric(doc, VT) Dim elemBoundingBox As BoundingBoxXYZ = elem.BoundingBox(View3D) max = elemBoundingBox.Max min = elemBoundingBox.Min centerOfBox = min.Add(max).Divide(2) rTrans.DoRollBackSubTran() Return centerOfBox Catch ex As Exception rTrans.DoRollBackSubTran() Return New Revit.DB.XYZ(0, 0, 0) End Try End Function Created By: Peter Mann (5/22/2012 1:54 PM) Hi Jeremy, My question is do you have a version of your code snippet updated for Revit 2013 that replaces the obsolete NewView3D? The update notes suggest CreateIsometric, but because this doesn't include the view direction, it will break your snippet? The direction will not matter if finding the centre of the bounding box, but it will if one wants the extents. http://thebuildingcoder.typepad.com/blog/2010/01/spot-elevation-creation-on- top-of-beam.html Privacy | Legal Description: http://na1.salesforce.com/servlet/servlet.ImageServer?oid=00D300000008uIL&es id=0183000000KEi1l
    Please use plain text.