Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Taging Linked Model Rooms

2 REPLIES 2
Reply
Message 1 of 3
david.rock
715 Views, 2 Replies

Taging Linked Model Rooms

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

 

2 REPLIES 2
Message 2 of 3
adam.nagy
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
Autodesk Platform Services
Message 3 of 3
david_rock
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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community