سؤال

I want to pass the parameter values to Revit family.I have spend many hours on google. In result i got few links which tells Read and Write Parameter Values with VB.NET Read and Write Parameter Values with VB.NET

in this example we are fetching parameters and writing a value in text file called ParametersValue.txt. But i am confused, how should i pass this file to Revit? I'm hoping someone can steer me in the right direction. I would really appreciate it!

هل كانت مفيدة؟

المحلول 3

I use C# when writing Revit API code because that's what all the samples are written in, but I might be able to get you pointed in the right direction with some additional details. Are you looking to assign a value to a specific parameter? For example: Height=30"? If so you first have to "get" the parameter. In the example in spidernet he goes through every parameter of a selected element:

Dim element As Autodesk.Revit.DB.Element = SelElement(cmdData.Application.ActiveUIDocument.Selection).Element 'Prompts you to select an element

For Each p As Parameter In element.Parameters 'Goes through every parameter in "element" and assigns the parameter to "p"
  If p.Definition.Name = "Height" Then 'Check if "p" is the name you want, "Height"
    p.Set(2.5) 'Because Revit knows FEET, so in order to type in 30in you use 2.5 
  End If
Next 'Loop through parameters

If you're looking for it to do something else, please post again.

Also, not sure you're aware, but a blog that is FULL is great Revit API info is Jeremy Tammik's: http://thebuildingcoder.typepad.com. A lot of his examples are C#, which is why I started learning C# instead of VB.NET.

If you don't have it already, make sure you get the SDK for Revit 2014 here: http://images.autodesk.com/adsk/files/Revit2014SDK_RTM0.exe

It has a TON of samples that might help too. Good Luck!

نصائح أخرى

One of the first things I would do after downloading the SDK mentioned in the previous post, is install the included revit lookup addin. This has been incredibly valuable in figuring what elements are called in the API, as well as determining which storage type the parameter is using. If all of the parameters you want to update are strings, those will be fairly straightforward to set from your text file. However, if,for example, the parameter value that you think is a string is actually set by an elementid, then there will be some coding involved to get the proper info to set the parameter value.

You can easily pass parameters to component families using "FamilyManager" class. The FamilyManager class provides access to family types and parameters. Just get the parameter and set its value. As we are working in family editor for component families, we have to load the parameter values in the project. I have tried this on Revit 2019. You have to

  1. Open family in family editor
  2. Activate the plugin
  3. Click on Load into Project button on addins ribbon.

Then check the parameter value in the properties of that family.

Public Sub SetParamtersForComponentFamilies(ByVal doc As Document, ByVal parameterValue As String)
  Dim f As Family = doc.OwnerFamily

  Using trans As Transaction = New Transaction(doc, "Creating transaction for parameters")
    trans.Start()
    Dim familyMgr As FamilyManager = doc.FamilyManager
    Dim n As Integer = familyMgr.Parameters.Size
    Dim comment As FamilyParameter = familyMgr.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_COMMENTS)
    familyMgr.Set(comment, parameterValue)
    TaskDialog.Show("Paramters", "TypeComments : Updated")
    trans.Commit()
  End Using
End Sub
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top