Tuesday 2 October 2012

Creating a 3D View

In my previous post, I explained that I was having trouble with creating a 3D view as I needed the viewfamilytypeid of the 3D view, which I believe can be different for each project, I figured out that I needed to create a collection of the viewFamilyTypes within the project and go through this until I found the ThreeDimensional viewfamily, so here is how I did it:


Using tx As New Transaction(doc)
            tx.Start("Create 3D View")
            Dim ThreeDViews As ICollection(Of Autodesk.Revit.DB.Element) = coll.OfClass(GetType(ViewFamilyType)).ToElements()
            For Each VFT As ViewFamilyType In ThreeDViews
                If VFT.ViewFamily = ViewFamily.ThreeDimensional Then
                    Dim ThreeDView As ViewFamilyType = VFT
                    Dim view3D As View3D = view3D.CreateIsometric(doc, ThreeDView.Id)
                    view3D.Name = "Drew's QTO Export View"
                    tx.Commit()
                    tx.Dispose()
                    uidoc.ActiveView = view3D
                End If
            Next
        End Using

Seems to work, so now to figure out how to isolate a category in the new view.... anyone have an idea?

Creating New View's

I have decided that I want to be able to export from my model certain categories of object for use in QTO (Check out QTO if you are interested in the quantification of elements within your model).

In order to do this I think it would be easiest if I clicked a button and views were made that are 3D with a particular category isolated.

This seemed to be easy in my head, I had already found out how to generate a new view, for example to make a new drafting view and set it as the current view I used:


Public Sub CreateNewDraftingView(ViewName As String)
        Dim uidoc As UIDocument = IncomingCleanup.uiapp.ActiveUIDocument
        Dim doc As Document = uidoc.Document
        Using tx As New Transaction(doc)
            tx.Start("Create Drafting View")
            Dim myDraftingView As ViewDrafting = doc.Create.NewViewDrafting()
            myDraftingView.ViewName = ViewName
            tx.Commit()
            uidoc.ActiveView = myDraftingView
        End Using
    End Sub

(By the way, for anyone interested in how to get colour coded text, all I do is copy the text from Visual Studio into Word 2010 then copy that text into Blogger)

to run it I simply need to use:

CreateNewDraftingView("Drew's Magic View")

so I figured it would be just as easy to make a 3D view, however, it turns our that's not the case...


Dim my3DView As View3D = View3D.CreateIsometric(doc,.......

is kind of what I need, however I need the ViewFamilyTypeID of a 3D view and I am a little stumped on how to get that, especially if I dont have existing 3D views in the project


I am going to go figure out how to do it and report back with this and how to then isolate categories in the view prior to exporting to DWF.