Automaticaly fil the column "Mark" field with data from the Column "Grid" field

Automaticaly fil the column "Mark" field with data from the Column "Grid" field

Anonymous
Not applicable
609 Views
2 Replies
Message 1 of 3

Automaticaly fil the column "Mark" field with data from the Column "Grid" field

Anonymous
Not applicable

 

 

 

Lets say i want to take the column location (grid Mark) field data and plug it into the "mark" field for the column....how do i do that?

 

 

and also my building has 2 floors but ive made the column in such a way that its a single column from the ground level tot the top of the second floor level how do i get the column data by level instead of a single 20 ft column?  ( is this Bad modelling Practice ? )

 

 

0 Likes
Accepted solutions (1)
610 Views
2 Replies
Replies (2)
Message 2 of 3

AGYEMANG.OFOSU
Advocate
Advocate

YOU MAY NEED DYNAMO FOR THAT. 

0 Likes
Message 3 of 3

RPTHOMAS108
Mentor
Mentor
Accepted solution

I've written the below document macro for this task, to be manually run each time column positions are changed.

 

In Macro Manager Create a new Module with language set to VB.Net

 

Capture0701a.PNG

 

Within SharpDevelop environment replace all the text in the 'ThisDocument.vb' window with the code below and compile the project with button below.

Capture0701b.PNG

 

Close SharpDevelop and run the macro by either double clicking or selecting it and pressing run.

Capture0701c.PNG

 

This code as is adds a level prefix to each column before adding the grid ref. You can prevent this behaviour by changing the line:

 

Const AddlevelRef As Boolean = True

 

To

 

Const AddlevelRef As Boolean = False

 

If you do this you'll likely get duplicate mark warnings. Unless you plan to detail full building height column lengths (which would be unusual) you'll have to split the columns per floor.

 

Imports System
Imports Autodesk.Revit.UI
Imports Autodesk.Revit.DB
Imports Autodesk.Revit.UI.Selection
Imports System.Collections.Generic
Imports System.Linq

<Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)> _
<Autodesk.Revit.DB.Macros.AddInId("B0059921-31C9-465D-8A56-08F5780F302A")> _
Partial Public Class ThisDocument
    Private Sub Module_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
	End Sub
	Private Sub Module_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
	End Sub
    
    Public sub TransferColLocToMark()
		Dim IntDoc As Document =Application.ActiveUIDocument.Document
        Dim FEC As New FilteredElementCollector(IntDoc)
        Dim ECF As New ElementCategoryFilter(BuiltInCategory.OST_StructuralColumns)
        Dim Els As ICollection(Of ElementId) = FEC.WherePasses(ECF).ToElementIds

        Const AddlevelRef As Boolean = True

        Dim GetColLev = Function(Item As Element) As String
                            Dim Lv As Level = TryCast(IntDoc.GetElement(Item.LevelId), Level)
                            If Lv Is Nothing Then Return Nothing Else 
                            Dim J As Double = Lv.Elevation
                            Dim P_Base As Parameter = Item.Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM)
                            If P_Base Is Nothing = False Then
                                J += P_Base.AsDouble
                            End If
                            If IntDoc.DisplayUnitSystem = DisplayUnit.METRIC Then
                                Dim J_m As Double = J * 0.3048 'ft to m
                                Return J_m.ToString("F1")
                            Else
                                Return J.ToString("F0")
                            End If
                        End Function

        Dim WKSharing As New List(Of ElementId)

        On Error Resume Next

        Using Tx As New Transaction(IntDoc, "Transfer grid ref to column mark.")
            If Tx.Start = TransactionStatus.Started Then


                For Each item As ElementId In Els
                    If IntDoc.IsWorkshared = True Then
                        Select Case WorksharingUtils.GetModelUpdatesStatus(IntDoc, item)
                            Case Is = ModelUpdatesStatus.DeletedInCentral, ModelUpdatesStatus.UpdatedInCentral
                                WKSharing.Add(item)
                                Continue For
                            Case Else
                        End Select
                        Select Case WorksharingUtils.GetCheckoutStatus(IntDoc, item)
                            Case Is = CheckoutStatus.OwnedByOtherUser
                                WKSharing.Add(item)
                                Continue For
                            Case Else
                        End Select
                    End If

                    Dim El As Element = IntDoc.GetElement(item)
                    If El Is Nothing Then Continue For Else 
                    Dim ColLoc As Parameter = El.Parameter(BuiltInParameter.COLUMN_LOCATION_MARK)
                    If ColLoc Is Nothing Then Continue For Else 

                    Dim MK As String = ColLoc.AsString
                    If String.IsNullOrEmpty(MK) = False Then
                        If AddlevelRef = True Then
                            MK = GetColLev(El) & " " & MK
                        End If

                        Dim P_mk As Parameter = El.Parameter(BuiltInParameter.ALL_MODEL_MARK)
                        If P_mk Is Nothing Then Continue For Else 
                        P_mk.Set(MK)
                    End If


                Next
                Tx.Commit()
            End If
        End Using

        If WKSharing.Count <> 0 Then
            TaskDialog.Show("Worksharing", "Some items could no be updated due to worksharing, synchronise and try again.", TaskDialogCommonButtons.Ok)
        End If        
 End Sub    
End Class

 

0 Likes