Skip to content

Commit e154c7f

Browse files
author
Jeremy Tammik
authored
Merge pull request #13 from NK29/master
Revit 2022 Migration-changes in Family API, Family documents updated
2 parents 332abcc + b8426fd commit e154c7f

10 files changed

+93
-73
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Labs/3_Revit_Family_API/SourceCS/2_ColumnLshape.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,16 @@ void addParameters()
503503

504504
// API parameter group for Dimension is PG_GEOMETRY:
505505
//
506+
ForgeTypeId builtinParamGroup = new ForgeTypeId(GroupTypeId.Geometry.TypeId);
507+
ForgeTypeId parameterTypeId = SpecTypeId.Length;
508+
506509
FamilyParameter paramTw = mgr.AddParameter(
507-
"Tw", BuiltInParameterGroup.PG_GEOMETRY,
508-
ParameterType.Length, false);
510+
"Tw", builtinParamGroup,
511+
parameterTypeId, false);
509512

510513
FamilyParameter paramTd = mgr.AddParameter(
511-
"Td", BuiltInParameterGroup.PG_GEOMETRY,
512-
ParameterType.Length, false);
514+
"Td", builtinParamGroup,
515+
parameterTypeId, false);
513516

514517
// set initial values:
515518
//

Labs/3_Revit_Family_API/SourceCS/3_ColumnFormulaMaterial.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,15 @@ void addParameters()
517517

518518
// API parameter group for Dimension is PG_GEOMETRY:
519519
//
520+
ForgeTypeId builtinParamGroup=new ForgeTypeId(GroupTypeId.Geometry.TypeId);
521+
ForgeTypeId parametertype = SpecTypeId.Length;
520522
FamilyParameter paramTw = mgr.AddParameter(
521-
"Tw", BuiltInParameterGroup.PG_GEOMETRY,
522-
ParameterType.Length, false);
523+
"Tw", builtinParamGroup,
524+
parametertype, false);
523525

524526
FamilyParameter paramTd = mgr.AddParameter(
525-
"Td", BuiltInParameterGroup.PG_GEOMETRY,
526-
ParameterType.Length, false);
527+
"Td", builtinParamGroup,
528+
parametertype, false);
527529

528530
// set initial values:
529531
//
@@ -793,7 +795,9 @@ public void addMaterials(Extrusion pSolid)
793795
// this time we use instance parameter so that we can change it at instance level.
794796
//
795797
FamilyManager pFamilyMgr = _doc.FamilyManager;
796-
FamilyParameter famParamFinish = pFamilyMgr.AddParameter("ColumnFinish", BuiltInParameterGroup.PG_MATERIALS, ParameterType.Material, true);
798+
ForgeTypeId builtinParamGroup = new ForgeTypeId(GroupTypeId.Materials.TypeId);
799+
ForgeTypeId parametertype = SpecTypeId.Reference.Material;
800+
FamilyParameter famParamFinish = pFamilyMgr.AddParameter("ColumnFinish", builtinParamGroup,parametertype, true);
797801

798802
// (2b.1) associate material parameter to the family parameter we just added
799803
//

Labs/3_Revit_Family_API/SourceCS/4_ColumnVisibility.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,15 +516,17 @@ void addParameters()
516516
{
517517
FamilyManager mgr = _doc.FamilyManager;
518518

519-
// API parameter group for Dimension is PG_GEOMETRY:
520-
//
519+
// API parameter group for Dimension is PG_GEOMETRY:
520+
//
521+
ForgeTypeId builtinParamgroupTypeId = new ForgeTypeId(GroupTypeId.Geometry.TypeId);
522+
ForgeTypeId parameterTypeId =SpecTypeId.Length;
521523
FamilyParameter paramTw = mgr.AddParameter(
522-
"Tw", BuiltInParameterGroup.PG_GEOMETRY,
523-
ParameterType.Length, false );
524+
"Tw", builtinParamgroupTypeId,
525+
parameterTypeId, false );
524526

525527
FamilyParameter paramTd = mgr.AddParameter(
526-
"Td", BuiltInParameterGroup.PG_GEOMETRY,
527-
ParameterType.Length, false );
528+
"Td", builtinParamgroupTypeId,
529+
parameterTypeId, false );
528530

529531
// set initial values:
530532
//
@@ -783,13 +785,14 @@ public void addMaterials( Extrusion pSolid )
783785
// (2a) this add a material to the solid base. but then, we cannot change it for each column.
784786
//
785787
//pSolid.Parameter("Material").Set(idMat)
786-
787788
// (2b) add a parameter for material finish
788789
//
789790
// this time we use instance parameter so that we can change it at instance level.
790791
//
792+
ForgeTypeId builtinParamgroupTypeId = new ForgeTypeId(GroupTypeId.Materials.TypeId);
793+
ForgeTypeId parameterTypeId = SpecTypeId.Reference.Material;
791794
FamilyManager pFamilyMgr = _doc.FamilyManager;
792-
FamilyParameter famParamFinish = pFamilyMgr.AddParameter( "ColumnFinish", BuiltInParameterGroup.PG_MATERIALS, ParameterType.Material, true );
795+
FamilyParameter famParamFinish = pFamilyMgr.AddParameter( "ColumnFinish", builtinParamgroupTypeId,parameterTypeId, true );
793796

794797
// (2b.1) associate material parameter to the family parameter we just added
795798
//

Labs/3_Revit_Family_API/SourceVB/2_ColumnLshape.vb

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -487,19 +487,21 @@ Public Class RvtCmd_FamilyCreateColumnLShape
487487
'' ============================================
488488
Sub addParameters()
489489

490-
'' parameter group for Dimension is PG_GEOMETRY in API
491-
''
492-
Dim paramTw As FamilyParameter = _doc.FamilyManager.AddParameter("Tw", BuiltInParameterGroup.PG_GEOMETRY, ParameterType.Length, False)
493-
Dim paramTd As FamilyParameter = _doc.FamilyManager.AddParameter("Td", BuiltInParameterGroup.PG_GEOMETRY, ParameterType.Length, False)
494-
495-
'' give initial values
496-
''
497-
Dim tw As Double = mmToFeet(150.0) ' hard coded for simplicity
498-
Dim td As Double = mmToFeet(150.0)
499-
_doc.FamilyManager.Set(paramTw, tw)
500-
_doc.FamilyManager.Set(paramTd, td)
501-
502-
End Sub
490+
'' parameter group for Dimension is PG_GEOMETRY in API
491+
''
492+
Dim builtinParamGroup As ForgeTypeId = New ForgeTypeId(GroupTypeId.Geometry.TypeId)
493+
Dim parameterTypeId As ForgeTypeId = SpecTypeId.Length
494+
Dim paramTw As FamilyParameter = _doc.FamilyManager.AddParameter("Tw", builtinParamGroup, parameterTypeId, False)
495+
Dim paramTd As FamilyParameter = _doc.FamilyManager.AddParameter("Td", builtinParamGroup, parameterTypeId, False)
496+
497+
'' give initial values
498+
''
499+
Dim tw As Double = mmToFeet(150.0) ' hard coded for simplicity
500+
Dim td As Double = mmToFeet(150.0)
501+
_doc.FamilyManager.Set(paramTw, tw)
502+
_doc.FamilyManager.Set(paramTd, td)
503+
504+
End Sub
503505

504506
'' ============================================
505507
'' (3.2) add dimensions

Labs/3_Revit_Family_API/SourceVB/3_ColumnFormulaMaterial.vb

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -497,16 +497,18 @@ Public Class RvtCmd_FamilyCreateColumnFormulaMaterial
497497
'' ============================================
498498
Sub addParameters()
499499

500-
'' (1) add dimensional parameters, Tw and Td.
501-
''
502-
'' parameter group for Dimension is PG_GEOMETRY in API
503-
''
504-
Dim paramTw As FamilyParameter = _doc.FamilyManager.AddParameter("Tw", BuiltInParameterGroup.PG_GEOMETRY, ParameterType.Length, False)
505-
Dim paramTd As FamilyParameter = _doc.FamilyManager.AddParameter("Td", BuiltInParameterGroup.PG_GEOMETRY, ParameterType.Length, False)
500+
'' (1) add dimensional parameters, Tw and Td.
501+
''
502+
'' parameter group for Dimension is PG_GEOMETRY in API
503+
''
504+
Dim builtinParamGroup As ForgeTypeId = New ForgeTypeId(GroupTypeId.Geometry.TypeId)
505+
Dim parametertype As ForgeTypeId = SpecTypeId.Length
506+
Dim paramTw As FamilyParameter = _doc.FamilyManager.AddParameter("Tw", builtinParamGroup, parametertype, False)
507+
Dim paramTd As FamilyParameter = _doc.FamilyManager.AddParameter("Td", builtinParamGroup, parametertype, False)
506508

507-
'' give initial values
508-
''
509-
Dim tw As Double = mmToFeet(150.0) ' hard coded for simplicity
509+
'' give initial values
510+
''
511+
Dim tw As Double = mmToFeet(150.0) ' hard coded for simplicity
510512
Dim td As Double = mmToFeet(150.0)
511513
_doc.FamilyManager.Set(paramTw, tw)
512514
_doc.FamilyManager.Set(paramTd, td)
@@ -757,20 +759,22 @@ Public Class RvtCmd_FamilyCreateColumnFormulaMaterial
757759
End If
758760
Dim idMat As ElementId = pMat.Id
759761

760-
'' (2a) this add a material to the solid base. but then, we cannot change it for each column.
761-
''
762-
'pSolid.Parameter("Material").Set(idMat)
762+
'' (2a) this add a material to the solid base. but then, we cannot change it for each column.
763+
''
764+
'pSolid.Parameter("Material").Set(idMat)
763765

764-
'' (2b) add a parameter for material finish
765-
''
766-
'' this time we use instance parameter so that we can change it at instance level.
767-
''
768-
Dim pFamilyMgr As FamilyManager = _doc.FamilyManager
769-
Dim famParamFinish As FamilyParameter = pFamilyMgr.AddParameter("ColumnFinish", BuiltInParameterGroup.PG_MATERIALS, ParameterType.Material, True)
766+
'' (2b) add a parameter for material finish
767+
''
768+
'' this time we use instance parameter so that we can change it at instance level.
769+
''
770+
Dim pFamilyMgr As FamilyManager = _doc.FamilyManager
771+
Dim builtinParamGroup As ForgeTypeId = New ForgeTypeId(GroupTypeId.Materials.TypeId)
772+
Dim parametertype As ForgeTypeId = SpecTypeId.Reference.Material
773+
Dim famParamFinish As FamilyParameter = pFamilyMgr.AddParameter("ColumnFinish", builtinParamGroup, parametertype, True)
770774

771-
'' (2b.1) associate material parameter to the family parameter we just added
772-
''
773-
pSolid.LookupParameter("Material").Set(idMat)
775+
'' (2b.1) associate material parameter to the family parameter we just added
776+
''
777+
pSolid.LookupParameter("Material").Set(idMat)
774778

775779
'' Dim paramMat As Parameter = pSolid.Parameter("Material")
776780

Labs/3_Revit_Family_API/SourceVB/4_ColumnVisibility.vb

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,14 @@ Public Class RvtCmd_FamilyCreateColumnVisibility
508508
'' ============================================
509509
Sub addParameters()
510510

511-
'' (1) add dimensional parameters, Tw and Td.
512-
''
513-
'' parameter group for Dimension is PG_GEOMETRY in API
514-
''
515-
Dim paramTw As FamilyParameter = _doc.FamilyManager.AddParameter("Tw", BuiltInParameterGroup.PG_GEOMETRY, ParameterType.Length, False)
516-
Dim paramTd As FamilyParameter = _doc.FamilyManager.AddParameter("Td", BuiltInParameterGroup.PG_GEOMETRY, ParameterType.Length, False)
511+
'' (1) add dimensional parameters, Tw and Td.
512+
''
513+
'' parameter group for Dimension is PG_GEOMETRY in API
514+
''
515+
Dim builtinParamgroupTypeId As ForgeTypeId = New ForgeTypeId(GroupTypeId.Geometry.TypeId)
516+
Dim parameterTypeId As ForgeTypeId = SpecTypeId.Length
517+
Dim paramTw As FamilyParameter = _doc.FamilyManager.AddParameter("Tw", builtinParamgroupTypeId, parameterTypeId, False)
518+
Dim paramTd As FamilyParameter = _doc.FamilyManager.AddParameter("Td", builtinParamgroupTypeId,parameterTypeId, False)
517519

518520
'' give initial values
519521
''
@@ -767,28 +769,30 @@ Public Class RvtCmd_FamilyCreateColumnVisibility
767769
End If
768770
Dim idMat As ElementId = pMat.Id
769771

770-
'' (2a) this add a material to the solid base. but then, we cannot change it for each column.
771-
''
772-
'pSolid.Parameter("Material").Set(idMat)
772+
'' (2a) this add a material to the solid base. but then, we cannot change it for each column.
773+
''
774+
'pSolid.Parameter("Material").Set(idMat)
773775

774-
'' (2b) add a parameter for material finish
775-
''
776-
'' this time we use instance parameter so that we can change it at instance level.
777-
''
778-
Dim pFamilyMgr As FamilyManager = _doc.FamilyManager
779-
Dim famParamFinish As FamilyParameter = pFamilyMgr.AddParameter("ColumnFinish", BuiltInParameterGroup.PG_MATERIALS, ParameterType.Material, True)
776+
'' (2b) add a parameter for material finish
777+
''
778+
'' this time we use instance parameter so that we can change it at instance level.
779+
''
780+
Dim pFamilyMgr As FamilyManager = _doc.FamilyManager
781+
Dim builtinParamgroupTypeId As ForgeTypeId = New ForgeTypeId(GroupTypeId.Materials.TypeId)
782+
Dim parameterTypeId As ForgeTypeId = SpecTypeId.Reference.Material
783+
Dim famParamFinish As FamilyParameter = pFamilyMgr.AddParameter("ColumnFinish", builtinParamgroupTypeId, parameterTypeId, True)
780784

781-
'' (2b.1) associate material parameter to the family parameter we just added
782-
''
785+
'' (2b.1) associate material parameter to the family parameter we just added
786+
''
783787

784-
'Dim paramMat As Parameter = pSolid.Parameter("Material")
788+
'Dim paramMat As Parameter = pSolid.Parameter("Material")
785789

786-
'' 'Get' accessor of 'Public ReadOnly Property Parameter(paramName As String) As Autodesk.Revit.DB.Parameter' is obsolete:
787-
'' 'This property is obsolete in Revit 2015
790+
'' 'Get' accessor of 'Public ReadOnly Property Parameter(paramName As String) As Autodesk.Revit.DB.Parameter' is obsolete:
791+
'' 'This property is obsolete in Revit 2015
788792

789-
'' Updated for Revit 2015
793+
'' Updated for Revit 2015
790794

791-
Dim paramMat As Parameter = pSolid.LookupParameter("Material")
795+
Dim paramMat As Parameter = pSolid.LookupParameter("Material")
792796

793797
pFamilyMgr.AssociateElementParameterToFamilyParameter(paramMat, famParamFinish)
794798

0 commit comments

Comments
 (0)