Top Banner
Join the conversation #AU2017 New API to Modify Visual Appearance of Materials in Revit Boris Shafiro Software Development Manager, Autodesk
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

Apr 13, 2018

Download

Documents

LêKhánh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
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

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

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

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

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

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

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

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

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

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

▪ 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

▪ 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

▪ 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

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

▪ 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

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

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
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

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

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

▪ 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

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

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

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

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

▪ 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

▪ 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

▪ 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

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

▪ 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

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
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

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

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.