Revit API

Reply
Active Member
explosive369
Posts: 6
Registered: ‎09-26-2012
Message 1 of 8 (1,646 Views)
Accepted Solution

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

1646 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?

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/Formulas_for_%22Everyday%22_Use 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
ADN Support Specialist
Joe.Ye
Posts: 328
Registered: ‎03-05-2010
Message 2 of 8 (1,627 Views)

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
Contractor
Developer Technical Services
Autodesk Developer Network
Active Member
explosive369
Posts: 6
Registered: ‎09-26-2012
Message 3 of 8 (1,621 Views)

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?

Valued Contributor
Revitalizer
Posts: 88
Registered: ‎09-07-2012
Message 4 of 8 (1,606 Views)

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

Active Member
explosive369
Posts: 6
Registered: ‎09-26-2012
Message 5 of 8 (1,591 Views)

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.

Valued Contributor
Revitalizer
Posts: 88
Registered: ‎09-07-2012
Message 6 of 8 (1,580 Views)

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
Valued Contributor
Revitalizer
Posts: 88
Registered: ‎09-07-2012
Message 7 of 8 (1,578 Views)

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 ;-(
Valued Contributor
Revitalizer
Posts: 88
Registered: ‎09-07-2012
Message 8 of 8 (1,575 Views)

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
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.