Results 1 to 7 of 7

Thread: shared parameters

  1. #1
    Member
    Join Date
    2012-12
    Posts
    9
    0 Did you find this post helpful? Yes

    Default shared parameters

    NEW to Revit API.

    I have seen the example - Revit 2013 SDK\Samples\ProjectInfo - which shows default project info on a form.

    I have created a sheet which contains new labels from attached shared parameter file.

    How can I load my new labels/attribute values onto a form - is this possible.

    Can I load each value into a seperate textbox?

    Any help would be much appreaciated.
    Attached Files Attached Files

  2. #2
    Member
    Join Date
    2012-12
    Location
    Boston, MA
    Posts
    7
    0 Did you find this post helpful? Yes

    Default Re: shared parameters

    Hi,

    I've provided some thoughts on how to do this at http://boostyourbim.wordpress.com/20...arameter-data/

    Regards
    Harry

  3. #3
    Member
    Join Date
    2012-12
    Posts
    9
    0 Did you find this post helpful? Yes

    Default Re: shared parameters

    Quote Originally Posted by harrymattison345771 View Post
    Hi,

    I've provided some thoughts on how to do this at http://boostyourbim.wordpress.com/20...arameter-data/

    Regards
    Harry
    Thanks for the link : when I try I get error :
    get_parameter is not a memeber of autodesk.revit.db.element on line:

    Code:
    Dim parameter AsParameter = e.get_Parameter("myproject")
    I have converted to vb.net

  4. #4
    Member
    Join Date
    2012-12
    Posts
    9
    0 Did you find this post helpful? Yes

    Default Re: shared parameters

    Have now tried:

    Code:
      Public Sub GetSheetParams()
    
            Dim doc As Document = Command.RevitStartInfo.RevitDoc
    
            Dim sheetInfo As String = ""
            For Each e As Element In New FilteredElementCollector(doc).OfClass(GetType(ViewSheet))
                ' get the parameter
                Dim parameter As Parameter = e.Parameter("myProjectNo")
    
    
                ' get the string value of the parameter
              Dim cadFileData = parameter.AsString
                sheetInfo += cadFileData + vbLf
            Next
            TaskDialog.Show("myProjectNo", sheetInfo)
        End Sub
    
    End Class
    but now get error : Object Reference not set to an instance of an object on line -
    Code:
    Dim cadFileData = parameter.AsString
    I am launching (GetSheetParams) from a button on my form - maybe this is wrong method.

    Any help is much appreciated.
    Last edited by info347074; 2012-12-17 at 07:47 PM.

  5. #5
    Member
    Join Date
    2012-09
    Posts
    28
    0 Did you find this post helpful? Yes

    Default Re: shared parameters

    Quote Originally Posted by info347074 View Post
    Have now tried:

    Code:
      Public Sub GetSheetParams()
    
            Dim doc As Document = Command.RevitStartInfo.RevitDoc
    
            Dim sheetInfo As String = ""
            For Each e As Element In New FilteredElementCollector(doc).OfClass(GetType(ViewSheet))
                ' get the parameter
                Dim parameter As Parameter = e.Parameter("myProjectNo")
    
    
                ' get the string value of the parameter
              Dim cadFileData = parameter.AsString
                sheetInfo += cadFileData + vbLf
            Next
            TaskDialog.Show("myProjectNo", sheetInfo)
        End Sub
    
    End Class
    but now get error : Object Reference not set to an instance of an object on line -
    Code:
    Dim cadFileData = parameter.AsString
    Any help is much appreciated.
    The parameter variable is null, meaning that the parameter was not found on that element. I see that the parameter name in the shared parameter file you posted is actually "ProjectNo" and not "myProjectNo". Make sure you've spelled the parameter name correctly - the name is also case sensitive so keep that in mind as well.

    If you want to explore an element's parameters, you should use RevitLookup which is part of the SDK. I don't think it comes pre-built so you'll need to compile it in Visual Studio and add the add-in to Revit yourself. It comes with instructions on how to do this.

  6. #6
    Member
    Join Date
    2012-12
    Posts
    9
    0 Did you find this post helpful? Yes

    Default Re: shared parameters

    Quote Originally Posted by cshha View Post
    The parameter variable is null, meaning that the parameter was not found on that element. I see that the parameter name in the shared parameter file you posted is actually "ProjectNo" and not "myProjectNo". Make sure you've spelled the parameter name correctly - the name is also case sensitive so keep that in mind as well.

    If you want to explore an element's parameters, you should use RevitLookup which is part of the SDK. I don't think it comes pre-built so you'll need to compile it in Visual Studio and add the add-in to Revit yourself. It comes with instructions on how to do this.
    I think it is this line that is returning nothing :
    Code:
     Dim parameter As Parameter = e.Parameter("ProjectNo")
    If I change it to one of the builtin parameters I get a value ie :
    Code:
      
    Dim myRevision AsParameter = e.Parameter(BuiltInParameter.SHEET_CURRENT_REVISION)

  7. #7
    Member
    Join Date
    2012-09
    Posts
    28
    0 Did you find this post helpful? Yes

    Default Re: shared parameters

    The parameter probably hasn't been added to the element yet then. When dealing with shared parameters, the parameter needs to be bound to the element before it can be set.

    Check out this post from Jeremy Tammik's blog. There's a link near the bottom to download a set of helper functions to deal with shared parameters. The function you'll be interested in is GetOrCreateElemSharedParam

    http://thebuildingcoder.typepad.com/...r-binding.html

Similar Threads

  1. How YOU use shared parameters
    By enerGwizz in forum Revit MEP - General
    Replies: 8
    Last Post: 2011-06-24, 08:55 PM
  2. Shared Parameters
    By revitrookie in forum Revit Architecture - General
    Replies: 5
    Last Post: 2009-07-31, 05:29 PM
  3. Shared Parameters
    By greg.gebert978266 in forum Revit Architecture - Families
    Replies: 1
    Last Post: 2008-05-16, 04:56 PM
  4. shared parameters
    By jhiggen in forum Revit - Platform
    Replies: 33
    Last Post: 2008-05-08, 12:50 AM
  5. Shared Parameters
    By neb1998 in forum Revit Architecture - General
    Replies: 7
    Last Post: 2007-04-13, 09:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •