It’s been a week since AU 2014 happened and it was such a great experience. I got to meet really interesting people and many of our ADN partners which are doing pretty amazing things with our API’s.
I met clients like Cl3ver which have a pretty interesting Platform for 3D presentations and they have native Revit plug-in which will make your model available reducing it up to 10 times for a faster and smoother presentation.
Another one that caught my eye was HsbCAD which have a very interesting plug-in that breaks your model into small pieces and makes them 3D print available adding parts to then get put together like a 3D puzzle, very interesting work.
During the exhibition I got to help the A360 team booth which turned out to be a total success with more than 4K visitors during the 3 days and got so many started with their free year subscription of A360. Also had the chance to meet incredible evangelist from my team which showed me how the logistics of ADN work and I couldn’t be happier that I’m part of this team.
Jeremy Tammik rocking the A360 booth.
During DevDays, Philippe Leefsma and Jim Quanci rocked the stage showing the Viewer and Data API with over 400 happy attendees.
Got a lot of selfies with our customers since being part of the ADN target list of #selfiewith there were many enthusiastic guys and girls trying to get us for the chance of scoring one of the coolest smart watches we were giving away.
DevHack was also a great experience on Tuesday afternoon, where we had many of our API’s developers come by for a consultation and we got the chance to help them with their current development projects. It was such a great time to meet all of those great developers in person after helping them for quite some time I was able to finally put a face to their name.
Jim Quanci rocking DevDays Stage.
Now back to Revit API. During the past couple of weeks I looked over a case where a developer was trying to get the material appearance's and bump image path.
Here is the question.
Question: How can I use the Revit API to retrieve the material appearance's generic and bump image file path and name.
foreach (Element elem in collector)
{
Material mat = elem as Material;
AppearanceAssetElement ae = (AppearanceAssetElement)
m_CurrentDocument.GetElement(mat.AppearanceAssetId);
Asset set = ae.GetRenderingAsset();
......
}
Answer: The asset has properties which are collections of name/value pairs. So these paths should be a part of the properties. Unfortunately there is no set of predefined values for the names, so you will need to experiment looking at the properties and then decide if you want to hardcode the names you are looking for, or try to find them dynamically.
(Sometimes the names change, and sometimes the available properties are different for different material types, so hard coding, while simplest, carries some possible risk).
I hope this helps, and let us know if you need more assistance from us.
Response: This is the code that I finally got it working.
void MyCommand(ExternalCommandData commandData)
{
string genericImage = "";
string bumpImage = "";
Element someElement = null; // have some material element here.
Material theMaterial = someElement as Material;
AppearanceAssetElement appearanceAsset =
(AppearanceAssetElement)commandData.Application.ActiveUIDocument.
Document.GetElement(theMaterial.AppearanceAssetId);
Asset asset1 = appearanceAsset.GetRenderingAsset();
genericImage = GetAssetProperty(asset1, "generic_diffuse");
bumpImage = GetAssetProperty(asset1, "generic_bump_map");
}
private string GetAssetProperty(Asset asset1, string propertyName)
{
const string BitmapPropertyName = "unifiedbitmap_Bitmap";
string theValue = "";
if (asset1 != null)
{
AssetProperty property;
AssetPropertyString stringProperty;
AssetProperty property2;
for (int i = 0; i < asset1.Size; i++)
{
property = asset1[i];
if (property != null && property.Name == propertyName)
{
IList<AssetProperty> propertiesConnected =
property.GetAllConnectedProperties();
if (propertiesConnected != null
&& propertiesConnected.Count > 0)
{
property2 = propertiesConnected[0];
if (property2.Type == AssetPropertyType.APT_Asset)
{
Asset asset2 = property2 as Asset;
if (asset2 != null)
{
for (int i2 = 0; i2 < asset2.Size; i2++)
{
property = asset2[i2];
if (property != null && property.Name
== BitmapPropertyName)
{
stringProperty = property
as AssetPropertyString;
if (stringProperty != null)
{
theValue = stringProperty.Value;
}
return theValue;
}
}
}
}
}
//Once the named property was found,
//we wont search next.
break;
}
}
}
return "";
}
Here is a screenshot of the information that we will be retrieving.
Thank you Jeff Yao from Applied Software for providing such a great and useful solution.
Thank you for reading and until next time.