• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Revit API

    Reply
    Active Member
    Posts: 6
    Registered: ‎09-26-2012
    Accepted Solution

    An object's Instance Id into a schedule in Revit Architecture

    296 Views, 7 Replies
    12-14-2012 06:50 AM

    I wish to get object's Instance Id numbers into the Revit Architecture schedules. I can obtain them using either the DB Link or the standard ODBC export, but the Instance Id's are not available in schedules. Is there a code that I can put into a schedule field that will transfer the Instance ID of the object into the shedule?

    Please use plain text.
    ADN Support Specialist
    Posts: 166
    Registered: ‎03-05-2010

    Re: An object's Instance Id into a schedule in Revit Architecture

    12-18-2012 11:40 PM in reply to: explosive369

     

    The workaround is you add a shared parameter to the target element, and then assign the element's Id value to this shared parameter. 

    Then create a schedule and include the shared parameter.

     

    Hope this helps.



    Joe Ye
    Developer Technical Services
    Autodesk Developer Network
    Please use plain text.
    Active Member
    Posts: 6
    Registered: ‎09-26-2012

    Re: An object's Instance Id into a schedule in Revit Architecture

    12-19-2012 01:28 AM in reply to: explosive369

    Hello Joe,

     

    Thank you for your post. How do I actually assign the element's Id value to the shared parameter? Is it a formula? What are the steps for assigning the Id to the parameter?

    Please use plain text.
    Valued Contributor
    Posts: 60
    Registered: ‎09-07-2012

    Re: An object's Instance Id into a schedule in Revit Architecture

    12-20-2012 01:54 AM in reply to: explosive369

    Hi explosive369,

     

    There is no need for a formula, just define a shared parameter of type integer and set its value like this:

    your_element.get_Parameter(your_parameter_name).Set(your_element.Id.IntegerValue)

     

    That's it.

     

    Best regards,

    Revitalizer

    Please use plain text.
    Active Member
    Posts: 6
    Registered: ‎09-26-2012

    Re: An object's Instance Id into a schedule in Revit Architecture

    12-21-2012 03:08 AM in reply to: Revitalizer

    Thank you Revitalizer for your post.

     

    With reference to the attached image, I have tried including the recommended code in both project and object family files. Ultimately, neither approach produced the six digit Revit Instance Id for each object within the schedule. Are the codes that I created incorrect? 

     

    Recommended code = your_element.get_Parameter(your_parameter_name).Set(your_element.Id.IntegerValue)

    Attempted code 1 = ExtSgl (3).get_Parameter(test_id).Set(door.Id.IntegerValue)

    Attempted code 2 = door.get_Parameter(test_id).Set(door.Id.IntegerValue)

     

    To reiterate, ultimately, I wish to be able to import the six digit Revit Instance Id's into schedules for every object. I am able to obtain them using the ODBC and DB Link options but I wish input them into schedules.

    Please use plain text.
    Valued Contributor
    Posts: 60
    Registered: ‎09-07-2012

    Re: An object's Instance Id into a schedule in Revit Architecture

    12-22-2012 12:32 AM in reply to: explosive369
    Hi explosive 369, you cannot use the code in the way you do. First, formula parameters are *family* related, meaning that you define them when editing families. In project context, there are no formula parameters (as far as I know). Second, syntax for formula parameters is different from the code we use in API: http://wikihelp.autodesk.com/Revit/enu/Community/Tips_and_Tricks/Families%2c_Parameters%2c_Formulas/... In formulas, you can refer to other exposed parameters but not to internal element properties (like the Id). So I would suggest you to implement a little add-in or macro for filling your test_id parameter values *programmatically*. You cannot perform this otherwise. Since this is the Revit *API* forum, you are on the right place here ;-) Get all the door instances, and for each door of them do: door.get_Parameter("test_id").Set(door.Id.IntegerValue); Make sure that each door you access already *has* this parameter at all before trying to set it. Ah, i see that your "test_id" parameter must be an *instance* parameter, not a *type* parameter, since each element has an *individual* Id value, of course. For filtering elements performantly, please look at the Revit SDK samples or visit The Building Coder: http://thebuildingcoder.typepad.com/ Hope this helpes you. Best regards, Revitalizer
    Please use plain text.
    Valued Contributor
    Posts: 60
    Registered: ‎09-07-2012

    Re: An object's Instance Id into a schedule in Revit Architecture

    12-22-2012 12:38 AM in reply to: Revitalizer
    Seems that my posting has a formatting problem since the aren't any line breaks, sorry for that ;-(
    Please use plain text.
    Valued Contributor
    Posts: 60
    Registered: ‎09-07-2012

    Re: An object's Instance Id into a schedule in Revit Architecture

    12-22-2012 12:57 AM in reply to: explosive369
    Hi explosive 369, additionally, you need to change the value type of your parameter from *text* to *integer* if you want to fill it with the integer value of ElementId.IntegerValue. If you want to use your parameter as a text parameter, you would need to fill it with door.Id.IntegerValue.ToString(). Best regards, Revitalizer
    Please use plain text.