Revit API

Reply
Member
Posts: 4
Registered: ‎10-16-2012
Message 1 of 4 (149 Views)

Unable to get material using "Materials.Contains(name)"

149 Views, 3 Replies
10-16-2012 02:08 AM

Hi,

 

I'm using Revit 2013. I want to get the material from a family document (e.g.

Material m = m_familyDocument.Settings.Materials.get_Item(name);). I used 2 different functions (Materials.Contains(string name) and Materials.get_Item(string name)) but both also giving me the following error: "Revit encountered a System.MissingMethodException: Method not found: 'Autodesk.Revit.DB.Materials Autodesk.Revit.DB.Settings.get_Materials()'." Am I allowed to retrieve material from a family document? What is the correct function to be used?

 

 

Thanks,

Chiou Hau

Valued Contributor
Posts: 72
Registered: ‎09-07-2012
Message 2 of 4 (146 Views)

Re: Unable to get material using "Materials.Contains(name)"

10-16-2012 02:24 AM in reply to: chiouhau

Dear chiouhau,

 

may it be that - when compiling - you have linked to the 2012 RevitAPI.dll while running the addin in Revit 2013 ?

I've noticed in another posting that you code for both 12 and 13, so maybe you use a 2012 method that is already deprecated in 2013 ?

 

 

Cheers,

Revitalizer

Member
Posts: 4
Registered: ‎10-16-2012
Message 3 of 4 (141 Views)

Re: Unable to get material using "Materials.Contains(name)"

10-16-2012 02:54 AM in reply to: Revitalizer

You are right. So is that means we must use different version of RevitAPI.dll if we want to run addin in different Revit version?

 

May I know what is the correct function used to get the material from family document if I only have the name? Thanks.

 

 

Valued Contributor
Posts: 72
Registered: ‎09-07-2012
Message 4 of 4 (137 Views)

Re: Unable to get material using "Materials.Contains(name)"

10-16-2012 03:01 AM in reply to: chiouhau

Hi,

 

here is more information about running code both with 2012 and 2013:

http://thebuildingcoder.typepad.com/blog/2012/07/multi-version-add-in.html

 

If you compile your code, you can see it in the compiler warnings which methods may disappear in following Revit API versions.

 

To answer the other question, getting materials by name from a family document: another one may give you more infos, I've no time...

 

Bye,

Revitalizer

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Revit

Twitter

Facebook

Blogs

Youtube