Skip to content

Commit

Permalink
removed unit related deprecated api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremytammik committed Jan 11, 2021
1 parent b774aba commit c492dd4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
9 changes: 6 additions & 3 deletions Labs/1_Revit_API_Intro/SourceCS/6_ExtensibleStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

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

Entity ent = new Entity(schema);
Field socketLocation = schema.GetField("SocketLocation");
ent.Set<XYZ>(socketLocation, new XYZ(2, 0, 0), DisplayUnitType.DUT_METERS);
//ent.Set<XYZ>( socketLocation, new XYZ( 2, 0, 0 ), DisplayUnitType.DUT_METERS ); // 2020
ent.Set<XYZ>(socketLocation, new XYZ(2, 0, 0), UnitTypeId.Meters ); // 2021

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

XYZ wallSocketPos = wallSchemaEnt.Get<XYZ>(
Schema.Lookup(_guid).GetField("SocketLocation"),
DisplayUnitType.DUT_METERS);
//DisplayUnitType.DUT_METERS ); // 2020
UnitTypeId.Meters ); // 2021

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

Expand Down
20 changes: 13 additions & 7 deletions Labs/1_Revit_API_Intro/SourceVB/6_ExtensibleStorage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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")
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit c492dd4

Please sign in to comment.