TitleBlock

TitleBlock

Anonymous
Not applicable
2,871 Views
10 Replies
Message 1 of 11

TitleBlock

Anonymous
Not applicable

HI, I am new in revit api

I have a sheet with a titleblock family

Family have shared parameters

i want to write a vb.net procedure that read the value of parameters. Where I can find a sample?

 

 

thanks

 

0 Likes
Accepted solutions (2)
2,872 Views
10 Replies
Replies (10)
Message 2 of 11

Joe.Ye
Alumni
Alumni

 

Hi Scarta,

 

You can use the shared paramter name to get the parameter , then read the parameter value.

 

Here is the code snippet to show how to read the shared parameter value from the title block.

 

<TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)> _
Public Class RevitCommand2
	Implements IExternalCommand
	Public Function Execute(commandData As ExternalCommandData, ByRef messages As String, elements As ElementSet) As Result

		Dim app As UIApplication = commandData.Application
		Dim doc As Document = app.ActiveUIDocument.Document

		Dim sel As Selection = app.ActiveUIDocument.Selection
		Dim ref1 As Reference = sel.PickObject(ObjectType.Element, "Please pick title block")
		Dim tb As FamilyInstance = TryCast(doc.GetElement(ref1), FamilyInstance)
		'''title block is a FamilyInstance 
		If tb Is Nothing Then
			Return Result.Failed
		End If


		'If the target shared parameter is from the family symbol/ family type.
		Dim param2 As Parameter = tb.get_Parameter("SharedParameterName")

		'If the target shared parameter is from the family instance.
		'Parameter param = tb.get_Parameter("SharedParameterName"); //directly use the shared parameter name


		'show the fire rating in task dialog
		TaskDialog.Show("target shared parameter value", param2.AsString())

		Return Result.Succeeded
	End Function
End Class


Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 3 of 11

Anonymous
Not applicable

HI,..

thanks I will try it!!

0 Likes
Message 4 of 11

Anonymous
Not applicable

i receive an error on the line tb.get_parameter the vb editor say "is not a member of autodesk.revit.db.familyistance"

 

any idea?

0 Likes
Message 5 of 11

Joe.Ye
Alumni
Alumni
Accepted solution

 

Sorry, I used the code converter to convert the C# to VB.net. The code was not converted completely correct.

 

Here is the one should work.

 

<TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)> _
Public Class RevitCommand2
	Implements IExternalCommand
	Public Function Execute(commandData As ExternalCommandData, ByRef messages As String, elements As ElementSet) As Result

		Dim app As UIApplication = commandData.Application
		Dim doc As Document = app.ActiveUIDocument.Document

		Dim sel As Selection = app.ActiveUIDocument.Selection
		Dim ref1 As Reference = sel.PickObject(ObjectType.Element, "Please pick title block")
		Dim tb As FamilyInstance = TryCast(doc.GetElement(ref1), FamilyInstance)
		'''title block is a FamilyInstance 
		If tb Is Nothing Then
			Return Result.Failed
		End If


		'If the target shared parameter is from the family symbol/ family type.
		Dim param2 As Parameter = tb.Parameter("SharedParameterName")

		'If the target shared parameter is from the family instance.
		'Parameter param = tb.Parameter("SharedParameterName"); //directly use the shared parameter name


		'show the fire rating in task dialog
		TaskDialog.Show("target shared parameter value", param2.AsString())

		Return Result.Succeeded
	End Function
End Class


Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 6 of 11

Anonymous
Not applicable

HI...

 

I have a problem with this line:

'Parameter param = tb.get_Parameter("SharedParameterName"); //directly use the

 

vb editor say "Can not use Parameter as expression" and param is not declared

0 Likes
Message 7 of 11

Joe.Ye
Alumni
Alumni

 

Hi Scarta,

 

Please remove the get_  from below line.

'Parameter param = tb.get_Parameter("SharedParameterName"); //directly use the

 

VB.NET doesn't need the get_ for when calling the class get properties.

 

Regards,



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 8 of 11

Anonymous
Not applicable

hi,

 

I have removed the _get but the problem is Parameter param, the error is: "Parameter is a type that can not be use as espression"

 

I post he total code:

Region

"Imports"

' Import the following name spaces in the project properties/references.

' Note: VB.NET has a slighly different way of recognizing name spaces than C#.

' if you explicitely set them in each .vb file, you will need to specify full name spaces.

'Imports System

'Imports Autodesk.Revit.DB

'Imports Autodesk.Revit.UI

'Imports Autodesk.Revit.ApplicationServices ' Application class

'Imports Autodesk.Revit.Attributes ' specific this if you want to save typing for attributes. e.g.,

'Imports Autodesk.Revit.UI.Selection ' for selection

Imports

Revit.Util.Constant

Imports

Revit.Util

Imports

System.Reflection

#End

Region

#Region

"Description"

' Revit Intro Lab - 2

'

' In this lab, you will learn how an element is represended in Revit.

' Disclaimer: minimum error checking to focus on the main topic.

'

#End

Region

 

'<Autodesk.Revit.Attributes.Regeneration(Attributes.RegenerationOption.Manual)>

'<Autodesk.Revit.Attributes.Transaction(Attributes.TransactionMode.Manual)>_

'<TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)> _

<

Transaction(TransactionMode.Automatic)> _

Public

ClassRevitCommand2ImplementsIExternalCommand

 

PublicFunctionExecute(commandDataAsExternalCommandData, ByRefmessagesAsString, elementsAsElementSet) AsResult_

 

ImplementsIExternalCommand.ExecuteDimappAsUIApplication = commandData.ApplicationDimdocAsDocument = app.ActiveUIDocument.DocumentDimselAsSelection = app.ActiveUIDocument.SelectionDimref1AsReference = sel.PickObject(ObjectType.Element, "Please pick title block")

 

DimtbAsFamilyInstance = TryCast(doc.GetElement(ref1), FamilyInstance)

 

'title block is a FamilyInstance

 

IftbIsNothingThenReturnResult.FailedEndIf

 

'If the target shared parameter is from the family symbol/ family type.DimSh_NameAsParameter = tb.Parameter(BuiltInParameter.SHEET_NAME)

 

DimSh_NumberAsParameter = tb.Parameter(BuiltInParameter.SHEET_NUMBER)

 

DimSh_ScaleAsParameter = tb.Parameter(BuiltInParameter.SHEET_SCALE)

 

DimparamAsParameter

 

 

'Dim param2 As Parameter = tb.Parameter("D2")'If the target shared parameter is from the family instance.Parameterparam = tb.Parameter("D2") '//directly use the shared parameter name

 

 

'show the fire rating in task dialog'TaskDialog.Show("target shared parameter value", param2.AsString())ReturnResult.Succeeded

 

 

 

End

Class

0 Likes
Message 9 of 11

Anonymous
Not applicable

hI..with this procedure i can retrieve built in parameter but when I check value for shared parameter i retrieve "nothing"

I have used bitchecker with the title block, but I not retrieved any shared parameter...

please download rvt file from http://www.fxcrender.com/download/u17.zip

 

this is the code: and i upload the rvt file

 

#Region "Imports"
' Import the following name spaces in the project properties/references. 
' Note: VB.NET has a slighly different way of recognizing name spaces than C#. 
' if you explicitely set them in each .vb file, you will need to specify full name spaces. 

'Imports System
'Imports Autodesk.Revit.DB
'Imports Autodesk.Revit.UI
'Imports Autodesk.Revit.ApplicationServices  ' Application class
'Imports Autodesk.Revit.Attributes ' specific this if you want to save typing for attributes. e.g., 
'Imports Autodesk.Revit.UI.Selection ' for selection 

Imports Revit.Util.Constant
Imports Revit.Util
Imports System.Reflection

#End Region

#Region "Description"
' Revit Intro Lab - 2 
' 
' In this lab, you will learn how an element is represended in Revit. 
' Disclaimer: minimum error checking to focus on the main topic. 
' 
#End Region


'<Autodesk.Revit.Attributes.Regeneration(Attributes.RegenerationOption.Manual)>
'<Autodesk.Revit.Attributes.Transaction(Attributes.TransactionMode.Manual)>_

'<TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)> _
<Transaction(TransactionMode.Automatic)> _
Public Class RevitCommand2
    Implements IExternalCommand


    Public Function Execute(commandData As ExternalCommandData, ByRef messages As String, elements As ElementSet) As Result _
        Implements IExternalCommand.Execute

        Dim app As UIApplication = commandData.Application
        Dim doc As Document = app.ActiveUIDocument.Document

        Dim sel As Selection = app.ActiveUIDocument.Selection
        Dim ref1 As Reference = sel.PickObject(ObjectType.Element, "Please pick title block")
        Dim tb As FamilyInstance = TryCast(doc.GetElement(ref1), FamilyInstance)
        'title block is a FamilyInstance 


        If tb Is Nothing Then
            Return Result.Failed
        End If


        'If the target shared parameter is from the family symbol/ family type.
        Dim Sh_Name As Parameter = tb.Parameter(BuiltInParameter.SHEET_NAME)
        'Dim Sh_Number As Parameter = tb.Parameter(BuiltInParameter.SHEET_NUMBER)
        'Dim Sh_Scale As Parameter = tb.Parameter(BuiltInParameter.SHEET_SCALE)





        'Dim param2 As Parameter = tb.Parameter("D2")

        'If the target shared parameter is from the family instance.
        'D2 is a shared parameter
        Dim param As Parameter = tb.Symbol.Parameter("D2") '//directly use the shared parameter name



        'show the fire rating in task dialog
        TaskDialog.Show("target shared parameter value", Sh_Name.AsString())

        Return Result.Succeeded



    End Function


End Class

 

0 Likes
Message 10 of 11

Anonymous
Not applicable

Can anyone help me?

 

I have installed Bitchecker and Revitlookup for check parameters, but the shared paramed are not show

 

0 Likes
Message 11 of 11

Anonymous
Not applicable
Accepted solution

Hi..

Ihave resolved the problem....I was finding the shared parameter on the Title block family, but sp was on the SHEET family!!

Thanks for your help!!

 

Stefano