Material database xml feed

General discussion about Indigo Materials - material requests, material developement, feedback, etc..
Post Reply
10 posts • Page 1 of 1
User avatar
benn
Posts: 1046
Joined: Mon Dec 08, 2008 12:47 pm
Location: Wellington, New Zealand
Contact:

Material database xml feed

Post by benn » Mon Jul 06, 2009 10:07 am

If you want to do some cool hacks with the material database - you might like this url:

http://indigorenderer.com/materials/mat ... xml?q=blue

It lets you search the materials database (just a fulltext search) and get the results as xml - which you can use to create a nice little UI for searching and using Indigo materials. :)

We've been thinking of opensourcing the material database so that you could run your own database in your organisation - might be handy if you had several hundred materials you share with other people in your company. Is anyone in this situation?

User avatar
Whaat
Developer
Posts: 1827
Joined: Fri Dec 22, 2006 6:15 am
Location: Canada
Contact:

Re: Material database xml feed

Post by Whaat » Mon Jul 06, 2009 1:23 pm

Ben,

I am able to open a web page using the SketchUp API but I am not sure how to call a function to get the XML feed without opening the user's web browser. Any ideas?

User avatar
benn
Posts: 1046
Joined: Mon Dec 08, 2008 12:47 pm
Location: Wellington, New Zealand
Contact:

Re: Material database xml feed

Post by benn » Mon Jul 06, 2009 2:43 pm

Your wish is my command - use jquery and load this url:

http://indigorenderer.com/materials/mat ... son?q=blue

You can then iterate over the materials with json.

$.loadJSON("http://indigorenderer.com/materials/mat ... son?q=blue", function(response){
$.each(response, function(){
alert(this.name);
});
});

Ben

User avatar
Whaat
Developer
Posts: 1827
Joined: Fri Dec 22, 2006 6:15 am
Location: Canada
Contact:

Re: Material database xml feed

Post by Whaat » Mon Jul 06, 2009 4:22 pm

This code does nothing. Can you please tell me what's missing? :)

Code: Select all

<html>
  <head>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>

    <script type="text/javascript">
       $(document).ready(function(){
	   $.load("http://indigorenderer.com/materials/materials/search.json?q=blue");
		$.loadJSON("http://indigorenderer.com/materials/materials/search.json?q=blue", function(response){
			$.each(response, function(){
				alert(this.name);
			});
		});
	});
  </script>
 
	</head>
<body>
  
</body>

</html>

User avatar
suvakas
3rd Place Winner
Posts: 2613
Joined: Mon Sep 04, 2006 11:08 pm
Location: Estonia
Contact:

Re: Material database xml feed

Post by suvakas » Mon Jul 06, 2009 11:46 pm

Hey Ben,

Would you be so kind and put the material and image urls back to xml please?
Strange, you just fixed the paths yesterday, but now the image and pigm url elements are gone completely? Those are kind of important.

User avatar
benn
Posts: 1046
Joined: Mon Dec 08, 2008 12:47 pm
Location: Wellington, New Zealand
Contact:

Re: Material database xml feed

Post by benn » Wed Jul 08, 2009 12:42 am

Fixed!

User avatar
suvakas
3rd Place Winner
Posts: 2613
Joined: Mon Sep 04, 2006 11:08 pm
Location: Estonia
Contact:

Re: Material database xml feed

Post by suvakas » Wed Jul 08, 2009 1:14 am

Thanks Ben !
Works Ok now.

User avatar
Whaat
Developer
Posts: 1827
Joined: Fri Dec 22, 2006 6:15 am
Location: Canada
Contact:

Re: Material database xml feed

Post by Whaat » Wed Aug 26, 2009 4:13 pm

ben,

Please take a look at this. I am using this code and I can't get the material names to display. Can you please post a full working example of how to use jquery to do the material database search? You would save me a world of frustration. Thanks

Code: Select all

<script type="text/javascript">
       $(document).ready(function(){
		$.getJSON("http://indigorenderer.com/materials/materials/search.json?q=blue", function(data){
			$.each(data, function(i,item){
				alert(data[i].name);
			});
		});
	});
  </script>

User avatar
Whaat
Developer
Posts: 1827
Joined: Fri Dec 22, 2006 6:15 am
Location: Canada
Contact:

Re: Material database xml feed

Post by Whaat » Wed Aug 26, 2009 4:24 pm

What do ya know? This works. :roll:

Code: Select all

$(document).ready(function(){
		$.getJSON("http://indigorenderer.com/materials/materials/search.json?q=blue", function(data){
			$.each(data, function(i,item){
				alert(item.material.name);
			});
		});
	});

User avatar
benn
Posts: 1046
Joined: Mon Dec 08, 2008 12:47 pm
Location: Wellington, New Zealand
Contact:

Re: Material database xml feed

Post by benn » Wed Aug 26, 2009 6:51 pm

Awesome! I'll help you out with the jquery stuff tomorrow if you have any other questions? :)

Post Reply
10 posts • Page 1 of 1

Who is online

Users browsing this forum: No registered users and 33 guests