Revit API

Reply
Contributor
david.rock
Posts: 21
Registered: ‎02-09-2011
Message 1 of 3 (446 Views)

Taging Linked Model Rooms

446 Views, 2 Replies
02-01-2012 10:38 PM

Hello,

 

I'm trying to tag all linked model rooms in the current view. Its weird, it looks line the room tags are there, I've added a selection, and it adds room tags to the selection, however none of them are visible.

 

Any help really apprectiated.

 

<Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)> _
<Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)> _
<Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)> _
Public Class TagAllLinkedRoomElementsCmd
    Implements Autodesk.Revit.UI.IExternalCommand

    Public Function Execute(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData, _
                             ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) _
                             As Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalCommand.Execute

        Dim activeDBdoc As Document = commandData.Application.ActiveUIDocument.Document
        Dim selSelectionElements As Autodesk.Revit.UI.Selection.SelElementSet = commandData.Application.ActiveUIDocument.Selection.Elements
        Dim objTransation As Transaction = clsRockitTransation.CreateNewTransation("Tag All Linked Room Elements", activeDBdoc)
        If objTransation IsNot Nothing Then
            Dim RoomTagTypeList As List(Of RoomTagType) = clsRockitElements.GetRoomTagTypes(activeDBdoc)
            If RoomTagTypeList.Count > 0 Then
                Dim objRoomTagType As RoomTagType = RoomTagTypeList.Item(1)
                MsgBox(objRoomTagType.Name)

                For Each doc As Document In commandData.Application.Application.Documents
                    Dim eleDocSpatialElements As List(Of Element) = clsRockitElements.Rockit_GetAllSpatialElements(doc)
                    For Each objElement As Element In eleDocSpatialElements
                        Dim objRoom As Room = TryCast(objElement, Room)
                        If objRoom IsNot Nothing Then
                            Dim locationPoint As LocationPoint = TryCast(objRoom.Location, LocationPoint)
                            Try
                                'MsgBox(locationPoint.Point.X.ToString)
                                Dim point As New Autodesk.Revit.DB.UV(locationPoint.Point.X, locationPoint.Point.Y)
                                Dim newTag As RoomTag = activeDBdoc.Create.NewRoomTag(objRoom, point, activeDBdoc.ActiveView)
                                newTag.RoomTagType = objRoomTagType
                                selSelectionElements.Add(newTag)
                                'MsgBox(objRoom.Name & " has been tagged...")
                            Catch ex As Exception
                                'MsgBox(ex.Message & objRoom.Name)
                            End Try
                        End If
                    Next
                Next
            End If
            objTransation.Commit()
        End If
    End Function
End Class

 

ADN Support Specialist
adam.nagy
Posts: 544
Registered: ‎03-26-2007
Message 2 of 3 (426 Views)

Re: Taging Linked Model Rooms

02-07-2012 06:14 PM in reply to: david.rock

Hi,

 

If you create the tags through the user interface then they are visible, right?

 

Maybe you could create one and compare it to the ones you created programmatically using the "Revit Lookup" tool that is part of the Revit SDK. That might give you an idea what is wrong with the ones you created programmatically.

 

I hope this helps.

 

Cheers,

Adam Nagy

Autodesk Developer Network



Adam Nagy
Developer Technical Services
Autodesk Developer Network
Active Member
david.rock
Posts: 7
Registered: ‎09-15-2011
Message 3 of 3 (413 Views)

Re: Taging Linked Model Rooms

02-11-2012 02:12 AM in reply to: david.rock

Thank you for the tip, I used the snoopdb tool, but on comparison between the two tags I could not see any difference. I tried to reconsile hosting but they are all OK.

 

I tried to copy the missing tag to the clipboard. I was thinking if I could copy & paste it, but I recive the following error message. I think it is a bug.

 

Selection cannot be copied. Can't Copy to Clipboard because of relationships between ElementsRoom Tags : M-RoomTag : Room Tag With Area : id 1497917

 

Even if there is a method that I can copy all the rooms from a linked model into the current model I could then tag the rooms.I know I can create spaces but they do not always get created successfully.

 

Thanks

David

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Revit

Twitter

Facebook

Blogs

Youtube