Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
explosive369
16645 Views, 11 Replies

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

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?

11 REPLIES 11
Message 2 of 12
Joe.Ye
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
Message 3 of 12
explosive369
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?

Message 4 of 12
Revitalizer
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




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 12
explosive369
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.

Tags (1)
Message 6 of 12
Revitalizer
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



Rudolf Honke
Software Developer
Mensch und Maschine





Message 7 of 12
Revitalizer
in reply to: Revitalizer

Seems that my posting has a formatting problem since the aren't any line breaks, sorry for that ;-(



Rudolf Honke
Software Developer
Mensch und Maschine





Message 8 of 12
Revitalizer
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



Rudolf Honke
Software Developer
Mensch und Maschine





Message 9 of 12
Gui.Talarico
in reply to: Revitalizer

3 years... there is a better solution:

https://www.youtube.com/watch?v=U-tVoCYilxo

Message 10 of 12
Revitalizer
in reply to: Gui.Talarico

Hi Gui.Talarico,

 

the video you refer to does just the same Joe Ye and I already have suggested.

Just using Dynamo instead of plain Revit API.

You also could write a little Macro or do it per Python console.

 

Still, I don't think there is another or even better solution for this topic.

Better than the shared parameter workaround would be a generic solution.

Autodesk could provide direct access to the ElementId of a schedule row.

 

Wait for Revit 2017 API...

 

 

Best regards,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 11 of 12
marc.desch.12
in reply to: Revitalizer

I know this been a while, but got this issues and really want to fix it. Where exactly do i put the formula. In your post you said : Get all the door instances, and for each door of them do: door.get_Parameter("test_id").Set(door.Id.IntegerValue)  What do you mean by *do*

When I enter it as the value of my shared parameter it pop-up to me :Formulas cannot refer to other parameters

Using Revit 2016

Thx,Regards

 

Message 12 of 12
Revitalizer
in reply to: marc.desch.12

Hi,

 

since this is the API forum, I suggest you to read the beginner stuff since your question tells me that you try to perform it in the Revit GUI.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community