Skip to content

Commit c492dd4

Browse files
author
Jeremy Tammik
committed
removed unit related deprecated api calls
1 parent b774aba commit c492dd4

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

Labs/1_Revit_API_Intro/SourceCS/6_ExtensibleStorage.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ public Result Execute(
132132

133133
// Set unit type
134134

135-
fieldBuilder1.SetUnitType(UnitType.UT_Length);
135+
//fieldBuilder1.SetUnitType( UnitType.UT_Length ); // 2020
136+
fieldBuilder1.SetSpec(SpecTypeId.Length); // 2021
136137

137138
// Add documentation (optional)
138139

@@ -151,7 +152,8 @@ public Result Execute(
151152

152153
Entity ent = new Entity(schema);
153154
Field socketLocation = schema.GetField("SocketLocation");
154-
ent.Set<XYZ>(socketLocation, new XYZ(2, 0, 0), DisplayUnitType.DUT_METERS);
155+
//ent.Set<XYZ>( socketLocation, new XYZ( 2, 0, 0 ), DisplayUnitType.DUT_METERS ); // 2020
156+
ent.Set<XYZ>(socketLocation, new XYZ(2, 0, 0), UnitTypeId.Meters ); // 2021
155157

156158
Field socketNumber = schema.GetField("SocketNumber");
157159
ent.Set<string>(socketNumber, "200");
@@ -194,7 +196,8 @@ public Result Execute(
194196

195197
XYZ wallSocketPos = wallSchemaEnt.Get<XYZ>(
196198
Schema.Lookup(_guid).GetField("SocketLocation"),
197-
DisplayUnitType.DUT_METERS);
199+
//DisplayUnitType.DUT_METERS ); // 2020
200+
UnitTypeId.Meters ); // 2021
198201

199202
s = "SocketLocation: " + Format.PointString(wallSocketPos);
200203

Labs/1_Revit_API_Intro/SourceVB/6_ExtensibleStorage.vb

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,16 @@ Friend Class ExtensibleStorage
125125

126126
' Create field1
127127

128-
Dim fieldBuilder1 As FieldBuilder = _
129-
builder.AddSimpleField("SocketLocation", GetType(XYZ)).SetUnitType(UnitType.UT_Length)
128+
Dim fieldBuilder1 As FieldBuilder =
129+
builder.AddSimpleField("SocketLocation", GetType(XYZ))
130+
131+
' .SetSpec(SpecTypeId.Length) ' 2021
132+
' GetType(XYZ)).SetUnitType(UnitType.UT_Length) ' 2020
130133

131134
' Set unit type
132135

133-
fieldBuilder1.SetUnitType(UnitType.UT_Length)
136+
'fieldBuilder1.SetUnitType(UnitType.UT_Length) ' 2020
137+
fieldBuilder1.SetSpec(SpecTypeId.Length) ' 2021
134138

135139
' Add documentation (optional)
136140

@@ -149,7 +153,8 @@ Friend Class ExtensibleStorage
149153

150154
Dim ent As New Entity(schema)
151155
Dim socketLocation As Field = schema.GetField("SocketLocation")
152-
ent.Set(Of XYZ)(socketLocation, New XYZ(2, 0, 0), DisplayUnitType.DUT_METERS)
156+
'ent.Set(Of XYZ)(socketLocation, New XYZ(2, 0, 0), DisplayUnitType.DUT_METERS) ' 2020
157+
ent.Set(Of XYZ)(socketLocation, New XYZ(2, 0, 0), UnitTypeId.Meters) ' 2021
153158

154159
Dim socketNumber As Field = schema.GetField("SocketNumber")
155160
ent.Set(Of String)(socketNumber, "200")
@@ -189,9 +194,10 @@ Friend Class ExtensibleStorage
189194

190195
Dim wallSchemaEnt As Entity = wall.GetEntity(schema.Lookup(_guid))
191196

192-
Dim wallSocketPos As XYZ = wallSchemaEnt.Get(Of XYZ)( _
193-
schema.Lookup(_guid).GetField("SocketLocation"), _
194-
DisplayUnitType.DUT_METERS)
197+
Dim wallSocketPos As XYZ = wallSchemaEnt.Get(Of XYZ)(
198+
Schema.Lookup(_guid).GetField("SocketLocation"),
199+
UnitTypeId.Meters) ' 2021
200+
' DisplayUnitType.DUT_METERS) ' 2020 _
195201

196202
s = "SocketLocation: " + Format.PointString(wallSocketPos)
197203

0 commit comments

Comments
 (0)