bsDD Hack to get ifcObject working in all browsers with Javascript

The Building SMART Data Dictionary is built to be accessed with API’s (application programming Interface) and this can be achieved from any internet enabled programming environment.

In the template library we implemented a call to retrieve the template description based on the templates IFCObject name.

In this example I get the return data in XML . I had some issues with how Internet explorer was handling parsing the data so added in a second pass of the data to handle this.

I use the JQuery JavaScript library extensively in our browser client end for formatting and parsing data. This simplifies the HTML code into addressable tags <DIV id=”[my Block Reference]” class=”[style it nicely with CSS]”></div>

You need to keep up to date with the API version but this should get you going.

// JavaScript Document
var bsDDId = ""
function getBsDD(ifcObjectType){
 

 $.ajax({
 type: 'GET',
 url: 'http://bsdd.buildingsmart.org/api/4.0/IfdConcept/search/' + ifcObjectType,
 contentType: 'application/x-www-form-urlencoded',
 data: {},
 dataType: 'xml',
 success: function (xmldoc) {
 $(xmldoc).find('IfdConcept').each(function(i) { 
 loop(this)
 }) 
 $(xmldoc).find('ns2\\:IfdConcept').each(function(i) { 
 loop(this)
 }) 
 }
 });
 
}

function loop(xml)
{
 $(xml).find('definitions').each(function(i) {
 
 if ($(this).find('languageCode').text() == "en-GB")
 { 
 $("#bsDDDescription").html($(this).find('description').text())
 loopGuid(xml, i)
 }
 if ($(this).find('languageCode').text() == "ifc-2X4")
 { 
 $("#bsDDDescriptionIFC").html($(this).find('description').text())
 loopGuidIFC(xml, i)
 } 
 })
}

function loopGuid(xml, c)
{

 $(xml).find('guid').each(function(i) {
 
 if (i == c)
 {
 bsDDId = $(this).text() 
 $("#bsDDId").val(bsDDId)
 $("#bsDDGuid").html($(this).text())
 
 } 
 })
}

function loopGuidIFC(xml, c)
{

 $(xml).find('guid').each(function(i) {
 
 if (i == c)
 {
 bsDDId = $(this).text() 
 $("#bsDDIdIFC").val(bsDDId)
 $("#bsDDGuidIFC").html($(this).text())
 
 } 
 })
}

Here is the return XML from the bsDD server where ifcObjectType = ifcSpace

 <?xml version="1.0" encoding="UTF-8"?>
<ifdConcepts>
 <ns2:IfdConcept xmlns:ns2="http://peregrine.catenda.no/objects">
 <guid>0TaYu0sQSHu000025QrE$V</guid>
 <definitions>
 <guid>0UmriAsQSHu000025QrE$V</guid>
 <language>
 <guid>36K5y0oTCHsm00051Mm008</guid>
 <languageCode>en-GB</languageCode>
 <nameInEnglish>ENGLISH</nameInEnglish>
 <nameInSelf>British English</nameInSelf>
 </language>
 <description>Definition from IAI: A space (IfcSpace) represents an area or volume bounded actually or theoretically. Spaces are areas or volumes that provide for certain functions within a building.</description>
 <descriptionType>DEFINITION</descriptionType>
 </definitions>
 <fullNames>
 <guid>0Umri0sQSHu000025QrE$V</guid>
 <language>
 <guid>36K5y0oTCHsm00051Mm008</guid>
 <languageCode>en-GB</languageCode>
 <nameInEnglish>ENGLISH</nameInEnglish>
 <nameInSelf>British English</nameInSelf>
 </language>
 <languageFamily>ENGLISH</languageFamily>
 <name>ifcspace</name>
 <nameType>FULLNAME</nameType>
 </fullNames>
 <status>DRAFT</status>
 <versionDate>2011.09.08</versionDate>
 <versionId>1 2011.09.08</versionId>
 <conceptType>DOCUMENT</conceptType>
 <shortNames>
 <guid>0UAiI0sQSHu000025QrE$V</guid>
 <language>
 <guid>36K5y0oTCHsm00051Mm008</guid>
 <languageCode>en-GB</languageCode>
 <nameInEnglish>ENGLISH</nameInEnglish>
 <nameInSelf>British English</nameInSelf>
 </language>
 <languageFamily>ENGLISH</languageFamily>
 <name>IfcSpace</name>
 <nameType>SHORTNAME</nameType>
 </shortNames>
 </ns2:IfdConcept>
 <ns2:IfdConcept xmlns:ns2="http://peregrine.catenda.no/objects">
 <guid>2YmRA0qWWHuO00025QrE$V</guid>
 <comments>
 <guid>0DVe220vfCvPfeYgjHeuX0</guid>
 <language>
 <guid>1ASQw0qJqHuO00025QrE$V</guid>
 <languageCode>ifc-2X4</languageCode>
 <nameInEnglish>IFC</nameInEnglish>
 <nameInSelf>IFC 2x4</nameInSelf>
 </language>
 <description>ApplicableClass</description>
 <descriptionType>COMMENT</descriptionType>
 </comments>
 <definitions>
 <guid>0fO0LhI$L0Qwn6Exl5$Ss2</guid>
 <language>
 <guid>1ASQw0qJqHuO00025QrE$V</guid>
 <languageCode>ifc-2X4</languageCode>
 <nameInEnglish>IFC</nameInEnglish>
 <nameInSelf>IFC 2x4</nameInSelf>
 </language>
 <description>An area or volume bounded actually or theoretically that provide for certain functions within a building.</description>
 <descriptionType>DEFINITION</descriptionType>
 </definitions>
 <definitions>
 <guid>0cTOZNnpXBIh5eVSq4C8Vj</guid>
 <language>
 <guid>3vvsOOoT0Hsm00051Mm008</guid>
 <languageCode>en</languageCode>
 <nameInEnglish>ENGLISH</nameInEnglish>
 <nameInSelf>International English</nameInSelf>
 </language>
 <description>An area or volume bounded actually or theoretically that provide for certain functions within a building.</description>
 <descriptionType>DEFINITION</descriptionType>
 </definitions>
 <fullNames>
 <guid>2YmRAAqWWHuO00025QrE$V</guid>
 <language>
 <guid>1ASQw0qJqHuO00025QrE$V</guid>
 <languageCode>ifc-2X4</languageCode>
 <nameInEnglish>IFC</nameInEnglish>
 <nameInSelf>IFC 2x4</nameInSelf>
 </language>
 <languageFamily>IFC</languageFamily>
 <name>IfcSpace</name>
 <nameType>FULLNAME</nameType>
 </fullNames>
 <fullNames>
 <guid>2ZMaa0qWWHuO00025QrE$V</guid>
 <language>
 <guid>3vvsOOoT0Hsm00051Mm008</guid>
 <languageCode>en</languageCode>
 <nameInEnglish>ENGLISH</nameInEnglish>
 <nameInSelf>International English</nameInSelf>
 </language>
 <languageFamily>ENGLISH</languageFamily>
 <name>space</name>
 <nameType>FULLNAME</nameType>
 </fullNames>
 <status>DRAFT</status>
 <versionDate>2012.07.20 03:17:13</versionDate>
 <versionId>1</versionId>
 <conceptType>SUBJECT</conceptType>
 </ns2:IfdConcept>
</ifdConcepts>

In a database environment you would store the bbDD Id and retrieve on that. After all the bsDD is part universal language depository and nobody is going to mess with a Guid are they?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s