From c492dd426c3058338671bfded24abe3bbb89c9ce Mon Sep 17 00:00:00 2001 From: Jeremy Tammik Date: Mon, 11 Jan 2021 19:33:18 +0100 Subject: [PATCH] removed unit related deprecated api calls --- .../SourceCS/6_ExtensibleStorage.cs | 9 ++++++--- .../SourceVB/6_ExtensibleStorage.vb | 20 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Labs/1_Revit_API_Intro/SourceCS/6_ExtensibleStorage.cs b/Labs/1_Revit_API_Intro/SourceCS/6_ExtensibleStorage.cs index 24098fa..8ce0814 100644 --- a/Labs/1_Revit_API_Intro/SourceCS/6_ExtensibleStorage.cs +++ b/Labs/1_Revit_API_Intro/SourceCS/6_ExtensibleStorage.cs @@ -132,7 +132,8 @@ public Result Execute( // Set unit type - fieldBuilder1.SetUnitType(UnitType.UT_Length); + //fieldBuilder1.SetUnitType( UnitType.UT_Length ); // 2020 + fieldBuilder1.SetSpec(SpecTypeId.Length); // 2021 // Add documentation (optional) @@ -151,7 +152,8 @@ public Result Execute( Entity ent = new Entity(schema); Field socketLocation = schema.GetField("SocketLocation"); - ent.Set(socketLocation, new XYZ(2, 0, 0), DisplayUnitType.DUT_METERS); + //ent.Set( socketLocation, new XYZ( 2, 0, 0 ), DisplayUnitType.DUT_METERS ); // 2020 + ent.Set(socketLocation, new XYZ(2, 0, 0), UnitTypeId.Meters ); // 2021 Field socketNumber = schema.GetField("SocketNumber"); ent.Set(socketNumber, "200"); @@ -194,7 +196,8 @@ public Result Execute( XYZ wallSocketPos = wallSchemaEnt.Get( Schema.Lookup(_guid).GetField("SocketLocation"), - DisplayUnitType.DUT_METERS); + //DisplayUnitType.DUT_METERS ); // 2020 + UnitTypeId.Meters ); // 2021 s = "SocketLocation: " + Format.PointString(wallSocketPos); diff --git a/Labs/1_Revit_API_Intro/SourceVB/6_ExtensibleStorage.vb b/Labs/1_Revit_API_Intro/SourceVB/6_ExtensibleStorage.vb index 5d0f9ba..a00686c 100644 --- a/Labs/1_Revit_API_Intro/SourceVB/6_ExtensibleStorage.vb +++ b/Labs/1_Revit_API_Intro/SourceVB/6_ExtensibleStorage.vb @@ -125,12 +125,16 @@ Friend Class ExtensibleStorage ' Create field1 - Dim fieldBuilder1 As FieldBuilder = _ - builder.AddSimpleField("SocketLocation", GetType(XYZ)).SetUnitType(UnitType.UT_Length) + Dim fieldBuilder1 As FieldBuilder = + builder.AddSimpleField("SocketLocation", GetType(XYZ)) + + ' .SetSpec(SpecTypeId.Length) ' 2021 + ' GetType(XYZ)).SetUnitType(UnitType.UT_Length) ' 2020 ' Set unit type - fieldBuilder1.SetUnitType(UnitType.UT_Length) + 'fieldBuilder1.SetUnitType(UnitType.UT_Length) ' 2020 + fieldBuilder1.SetSpec(SpecTypeId.Length) ' 2021 ' Add documentation (optional) @@ -149,7 +153,8 @@ Friend Class ExtensibleStorage Dim ent As New Entity(schema) Dim socketLocation As Field = schema.GetField("SocketLocation") - ent.Set(Of XYZ)(socketLocation, New XYZ(2, 0, 0), DisplayUnitType.DUT_METERS) + 'ent.Set(Of XYZ)(socketLocation, New XYZ(2, 0, 0), DisplayUnitType.DUT_METERS) ' 2020 + ent.Set(Of XYZ)(socketLocation, New XYZ(2, 0, 0), UnitTypeId.Meters) ' 2021 Dim socketNumber As Field = schema.GetField("SocketNumber") ent.Set(Of String)(socketNumber, "200") @@ -189,9 +194,10 @@ Friend Class ExtensibleStorage Dim wallSchemaEnt As Entity = wall.GetEntity(schema.Lookup(_guid)) - Dim wallSocketPos As XYZ = wallSchemaEnt.Get(Of XYZ)( _ - schema.Lookup(_guid).GetField("SocketLocation"), _ - DisplayUnitType.DUT_METERS) + Dim wallSocketPos As XYZ = wallSchemaEnt.Get(Of XYZ)( + Schema.Lookup(_guid).GetField("SocketLocation"), + UnitTypeId.Meters) ' 2021 + ' DisplayUnitType.DUT_METERS) ' 2020 _ s = "SocketLocation: " + Format.PointString(wallSocketPos)