![Page 1: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/1.jpg)
Join the conversation #AU2017Join the conversation #AU2017
New API to Modify Visual Appearance of Materials in RevitBoris Shafiro
Software Development Manager, Autodesk
![Page 2: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/2.jpg)
Learn how to
▪ use new API to modify visual appearance of Materials in Revit
▪ navigate coding workflow to edit appearance assets
▪ use multiple schemas for regular and advanced materials in Revit
▪ write a sample plug-in for basic modification of the visual
appearance of Revit materials
Learning Objectives
![Page 3: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/3.jpg)
The Basics
![Page 4: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/4.jpg)
Materials API
Appearance
properties
Thermal &
energy-related
properties
Physical &
structural
properties
Shaded view
graphics
Basic Element
Info (name,
tags)
![Page 5: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/5.jpg)
Terminology
TERM DEFINITION
Revit MaterialAn element representing a material, made of a collection of property sets
AssetThe class representing a package of
properties
Appearance Asset Asset representing visual material properties
Appearance Asset Element
An element that stores an appearance asset
Asset Property One particular property of an asset
![Page 6: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/6.jpg)
Material API building blocks
Material
AppearanceAssetId
AppearanceAssetElement
GetRenderingAsset()
AssetAssetProperty 1 …AssetProperty N
[“name_string” ] orFindByName(name)
AssetProperty
GetSingleConnectedAsset()
Namespace Revit.DB Namespace Revit.DB.Visual
![Page 7: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/7.jpg)
Visual Materials UI
![Page 8: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/8.jpg)
Visual Materials UI (continued)
![Page 9: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/9.jpg)
New Editing Capabilities in Materials API
![Page 10: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/10.jpg)
▪ AppearanceAssetEditScope
▪ Start() Contains one Asset
▪ Commit() (plus all connected Assets)
▪ Cancel()
Edit Scope
![Page 11: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/11.jpg)
▪ AssetPropertyString.Value
▪ AssetPropertyBoolean.Value
▪ AssetPropertyInteger.Value
▪ AssetPropertyDouble.Value
▪ AssetPropertyFloat.Value
▪ AssetPropertyEnum.Value
▪ AssetPropertyDistance.Value (not always in feet)
New Writable Properties
![Page 12: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/12.jpg)
▪ AssetPropertyDoubleArray3d.SetValueAsXYZ()
▪ AssetPropertyDoubleArray4d.SetValueAsDoubles()
▪ AssetPropertyDoubleArray4d.SetValueAsColor()
▪ AssetPropertyList - add, insert, remove
New Methods
![Page 13: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/13.jpg)
Coding Workflow to Edit a Color
using(AppearanceAssetEditScope editScope = new AppearanceAssetEditScope(document))
{ Asset editableAsset = editScope.Start(assetElem.Id);
AssetPropertyDoubleArray4d genericDiffuseProperty = editableAsset["generic_diffuse"] as AssetPropertyDoubleArray4d;
genericDiffuseProperty.SetValueAsColor(color);
editScope.Commit(true); }
![Page 14: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/14.jpg)
▪ AssetProperty.GetSingleConnectedAsset()
▪ AssetProperty.RemoveConnectedAsset()
▪ AssetProperty.AddConnectedAsset (String schemaId)
▪ AssetProperty.AddCopyAsConnectedAsset(Asset renderingAsset)
Connected Assets
![Page 15: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/15.jpg)
Coding Workflow to Edit a Connected Assetusing(AppearanceAssetEditScope editScope
= new AppearanceAssetEditScope(document)) {
Asset editableAsset = editScope.Start(assetElem.Id); AssetProperty bumpMapProperty = editableAsset["generic_bump_map"];Asset connectedAsset = bumpMapProperty.GetSingleConnectedAsset(); if (connectedAsset != null) {
AssetPropertyString bumpmapBitmapProperty = connectedAsset["unifiedbitmap_Bitmap"] as AssetPropertyString;
if (bumpmapBitmapProperty.IsValidValue(bumpmapImageFilepath)) bumpmapBitmapProperty.Value = bumpmapImageFilepath;
} editScope.Commit(true);
}
![Page 16: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/16.jpg)
Demo
![Page 17: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/17.jpg)
![Page 18: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/18.jpg)
Schemas and Property Names
![Page 19: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/19.jpg)
Standard Material Schemas
▪ MetallicPaint
▪ Mirror
▪ PlasticVinyl
▪ SolidGlass
▪ Stone
▪ WallPaint
▪ Water
▪ Ceramic
▪ Concrete
▪ Generic
▪ Glazing
▪ Hardwood
▪ MasonryCMU
▪ Metal
![Page 20: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/20.jpg)
▪ AdvancedLayered
▪ AdvancedMetal
▪ AdvancedOpaque
▪ AdvancedTransparent
▪ AdvancedWood
Advanced Material Schemas
![Page 21: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/21.jpg)
Common Schema
![Page 22: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/22.jpg)
Schemas for Connected Assets
▪ Speckle
▪ Tile
▪ UnifiedBitmap
▪ Wave
▪ Wood
▪ BumpMap
▪ Checker
▪ Gradient
▪ Marble
▪ Noise
![Page 23: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/23.jpg)
UnifiedBitmap
![Page 24: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/24.jpg)
Property Names
AssetPropertyDoubleArray4d genericDiffuseProperty= editableAsset["generic_diffuse"]
as AssetPropertyDoubleArray4d;
equivalent
AssetPropertyDoubleArray4d genericDiffuseProperty = editableAsset[Generic.GenericDiffuse]
as AssetPropertyDoubleArray4d;
![Page 25: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/25.jpg)
▪ AssetPropertyString path =
asset[UnifiedBitmap.UnifiedbitmapBitmap] as AssetPropertyString;
Path is relative if inside default Material Library or
in Options/Rendering/Additional Render Appearance Paths;
Path is absolute otherwise.
Special Cases
![Page 26: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/26.jpg)
▪ AssetPropertyDoubleArray4d color = asset[Generic.DiffuseColor]
as AssetPropertyDoubleArray4d;
The Value of this AssetProperty is ignored if there is a connected Asset.
Special Cases (continued)
![Page 27: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/27.jpg)
▪ AssetPropertyReference reference;
Does not have a Value. Used only to have a connected Asset.
Special Cases (continued)
![Page 28: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/28.jpg)
SDK Sample
![Page 29: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/29.jpg)
▪ Bring up a modeless dialog
▪ Select a Painted Face
▪ Get Appearance Asset
▪ Get Tint Color AssetProperty
▪ Increment red/green/blue
AppearanceAssetEditing
![Page 30: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/30.jpg)
Demo
![Page 31: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/31.jpg)
![Page 32: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/32.jpg)
Q & A
![Page 33: New API to Modify Visual Appearance of Materials in Revitthebuildingcoder.typepad.com/...materials_api_boris_shafiro_slides.pdf · Learn how to use new API to modify visual appearance](https://reader030.vdocument.in/reader030/viewer/2022012312/5acfe0ef7f8b9a71028d38e0/html5/thumbnails/33.jpg)
Autodesk and the Autodesk logo are registered trademarks or trademarks of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and/or other countries. All other brand names, product names, or trademarks belong to their respective holders. Autodesk reserves the right to alter product and services offerings, and specifications and pricing at any time without notice, and is not responsible for typographical or graphical errors that may appear in this document.
© 2017 Autodesk. All rights reserved.