Object properties. (Lab 5)

Содержание

Слайд 2

Object Properties Find Properties Agenda

Object Properties
Find Properties

Agenda

Слайд 3

Object Properties

Object Properties

Слайд 4

ModelItem.PropertyCategories PropertyCategoryCollection PropertyCategory PropertyCategory.Properties DataPropertyCollection DataProperty Current .NET API cannot modify/add

ModelItem.PropertyCategories
PropertyCategoryCollection
PropertyCategory
PropertyCategory.Properties
DataPropertyCollection
DataProperty
Current .NET API cannot modify/add custom properties. Need COM API


.NET API

Слайд 5

Meaningful name Independent of languages Pre-define strings, easy to use Internal

Meaningful name
Independent of languages
Pre-define strings, easy to use
Internal name
Independent

of languages
Named from the class definition of API
Display name
What the end users can see in
Localization

Properties Name

Слайд 6

NamedConstant Identifier for a value combining the internal constant's name and

NamedConstant
Identifier for a value combining the internal constant's name and a

localized display name equivalent
VariantData
A value type that can store data of one of several different types
DataProperty.Value
Check type before print out the value

NamedConstant & VariantData

Слайд 7

Iterate Properties Demo Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument; if (oDoc.CurrentSelection.SelectedItems.Count > 0)

Iterate Properties Demo

Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument;
if (oDoc.CurrentSelection.SelectedItems.Count > 0)
{
StringBuilder

output = new StringBuilder(1000);
output.Append("Dump Property Category of Current Selected Item\n");
//dump the first item only
ModelItem oItem = oDoc.CurrentSelection.SelectedItems[0];
foreach (PropertyCategory oPC in oItem.PropertyCategories)
{
//each category
output.Append(" Display Name: " + oPC.DisplayName + " Internal Name" + oPC.Name + "\n");
output.Append(" Properties\n");
foreach (DataProperty oDP in oPC.Properties)
{
//each property
output.Append(" [Display Name]: " + oDP.DisplayName + "[Internal Name]:" + oDP.Name);
if (oDP.Value.IsDisplayString)
//if the value is display string
output.Append("[Value]: " + oDP.Value.ToString() + "\n");
else if (oDP.Value.IsDateTime)
//if the value is a date
output.Append("[Value]: " + oDP.Value.ToDateTime().ToShortTimeString() + "\n");
else
//other types
output.Append("" + "\n");
}
}
}
Слайд 8

PropertyCategoryCollection Various methods to get property category and property, e.g. FindCategoryByDisplayName

PropertyCategoryCollection
Various methods to get property category and property, e.g.
FindCategoryByDisplayName
find property

category by display name only
FindCategoryByName
find property category by internal name only
FindPropertyByDisplayName
find property by display name only
FindPropertyByName
find property by internal name only

Get Property by Method

Слайд 9

Demo: Get Categories by Display Name ModelItem oSelectedItem = oDoc.SelectedItems.ElementAt (0);

Demo: Get Categories by Display Name

ModelItem oSelectedItem = oDoc.SelectedItems.ElementAt(0);
//get

property category by display name
PropertyCategory oPC_DWGHandle =
oSelectedItem.PropertyCategories.FindCategoryByDisplayName("Entity Handle");
//by internal name
PropertyCategory oPC_DWGHandle1 =
oSelectedItem.PropertyCategories.FindCategoryByName
(PropertyCategoryNames.AutoCadEntityHandle);
//by combined name
PropertyCategory oPC_DWGHandle2 =
oSelectedItem.PropertyCategories.FindCategoryByCombinedName(new
NamedConstant(PropertyCategoryNames.AutoCadEntityHandle, "Entity Handle"));
Слайд 10

Demo: Get Categories by Methods ModelItem oSelectedItem = oDoc.SelectedItems.ElementAt (0); //get

Demo: Get Categories by Methods

ModelItem oSelectedItem = oDoc.SelectedItems.ElementAt(0);
//get property category

/by display name
PropertyCategory oPC_DWGHandle =
oSelectedItem.PropertyCategories.FindCategoryByDisplayName("Entity Handle");
//by internal name
PropertyCategory oPC_DWGHandle1 =
oSelectedItem.PropertyCategories.FindCategoryByName
(PropertyCategoryNames.AutoCadEntityHandle);
//by combined name
PropertyCategory oPC_DWGHandle2 =
oSelectedItem.PropertyCategories.FindCategoryByCombinedName(new
NamedConstant(PropertyCategoryNames.AutoCadEntityHandle, "Entity Handle"));
Слайд 11

Demo: Get Properties by Methods //by display name (property caterogy and

Demo: Get Properties by Methods
//by display name (property caterogy

and property)
DataProperty oDP_DWGHandle =
oSelectedItem.PropertyCategories.FindPropertyByDisplayName("Entity Handle", "Value");
//by internal name
DataProperty oDP_DWGHandle1 =
oSelectedItem.PropertyCategories.FindPropertyByName(PropertyCategoryNames.AutoCadEntityHandle,
DataPropertyNames.AutoCadEntityHandleValue);
//by combined name
DataProperty oDP_DWGHandle2 =
oSelectedItem.PropertyCategories.FindPropertyByCombinedName(
new NamedConstant(PropertyCategoryNames.AutoCadEntityHandle, "Entity Handle"
new NamedConstant(DataPropertyNames.AutoCadEntityHandleValue, "Value"));
//display the value of the DWG handle
System.Diagnostics.Debug.Write(oDP_DWGHandle.Value.ToString());
Слайд 12

See Lab 09 [COM Interop] Add Custom Properties

See Lab 09 [COM Interop]

Add Custom Properties

Слайд 13

ModelItem.InstanceGuid Same to Item>>Guid in UI Available for some file formats

ModelItem.InstanceGuid
Same to Item>>Guid in UI
Available for some file formats only (Revit,

AutoCAD)
Properties from source CAD file
Some format provides a kind of ID that could be an identifier such as AutoCAD Handle, Guid of Microstation.
Revit file
Recommend with Elements Properties>>UniqueId.

Unique Identifier of Object

Слайд 14

Create a plugin Check the language of Navisworks. Use the display

Create a plugin
Check the language of Navisworks.
Use the display name of

local language to find some properties

Exercise