Skip to content

Commit

Permalink
maintain new api R24
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Aug 23, 2023
1 parent 58fb71e commit d4da6c5
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 4 deletions.
6 changes: 6 additions & 0 deletions OpenMEPRevit/Application/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ public static string SnoopElementById(List<string> id)
List<global::Revit.Elements.Element> elements = new List<global::Revit.Elements.Element>();
foreach (string s in id)
{
#if R20 || R21 || R22 || R23
ElementId elementId = new ElementId(int.Parse(s));

#else
ElementId elementId = new ElementId(long.Parse(s));

#endif
global::Revit.Elements.Element element = document.GetElement(elementId).ToDynamoType();
elements.Add(element);
}
Expand Down
7 changes: 6 additions & 1 deletion OpenMEPRevit/Element/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,13 @@ private Element()
{
levelId = levelPara.AsElementId();
}

#if R20 || R21 || R22 || R23
if (levelId.IntegerValue == -1)

#else
if (levelId.Value == -1)

#endif
{
// General get level method
var bbox = element.get_BoundingBox(null);
Expand Down
5 changes: 5 additions & 0 deletions OpenMEPRevit/Element/Family/FamilyParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ public static Autodesk.Revit.DB.Definition Definition(Autodesk.Revit.DB.FamilyPa
{
Definition? definition = familyParameter?.Definition;
string? formula = familyParameter?.Formula;
#if R20 || R21 || R22 || R23
int? id = familyParameter?.Id.IntegerValue;
#else
long? id = familyParameter?.Id.Value;

#endif
ParameterSet? parameterSet = familyParameter?.AssociatedParameters;
List<global::Revit.Elements.Parameter?> associatedParameters = new List<global::Revit.Elements.Parameter?>();
bool? isInstance = familyParameter?.IsInstance;
Expand Down
4 changes: 4 additions & 0 deletions OpenMEPRevit/Element/MEPCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ private static void AdjustMepCurve(Autodesk.Revit.DB.Element mepCurve, XYZ p1, X
{
Connector? current = enumerator.Current as Autodesk.Revit.DB.Connector;
if (current == null) continue;
#if R20 || R21 || R22 || R23
if (current.Owner.Id.IntegerValue == mepCurve1.Id) continue;
#else
if (current.Owner.Id.Value == mepCurve1.Id) continue;
#endif
if (current.Owner is Autodesk.Revit.DB.Plumbing.PipingSystem) continue;
global::Revit.Elements.Element? dynamoType = current.Owner.ToDynamoType();
return dynamoType;
Expand Down
6 changes: 6 additions & 0 deletions OpenMEPRevit/Element/Pipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,13 @@ public static double GetRoughness(global::Revit.Elements.Element pipe)
Autodesk.Revit.DB.Plumbing.Pipe? pipeInternalElement = pipe.InternalElement as Autodesk.Revit.DB.Plumbing.Pipe;
Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
TransactionManager.Instance.EnsureInTransaction(doc);
#if R20 || R21 || R22 || R23
pipeInternalElement?.SetSystemType(new ElementId(systemTypeId));

#else
pipeInternalElement?.SetSystemType(new ElementId((long)systemTypeId));

#endif
TransactionManager.Instance.TransactionTaskDone();
return pipe;
}
Expand Down
11 changes: 11 additions & 0 deletions OpenMEPRevit/Helpers/Convert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ internal static class Convert
internal static dynCategory? ToDynamoType(this rvtCategory item)
{
if (item == null) throw new ArgumentNullException(nameof(item));
#if R20 || R21 || R22 || R23
return dynCategory.ById(item.Id.IntegerValue);

#else
return dynCategory.ById(item.Id.Value);

#endif
}

/// <summary>
Expand Down Expand Up @@ -175,7 +181,12 @@ internal static rvtCategory ToRevitType(
internal static dynElement ToDynamoType(this ElementId item)
{
if (item == null) throw new ArgumentNullException(nameof(item));
#if R20 || R21 || R22 || R23
return dynElementSelector.ByElementId(item.IntegerValue);
#else
return dynElementSelector.ByElementId(item.Value);

#endif
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion OpenMEPRevit/OpenMEPRevit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<DefineConstants>$(DefineConstants);R24</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Release R24'))">
<DynamoVersion>2.16</DynamoVersion>
<DynamoVersion>2.17</DynamoVersion>
<DynamoOutput>2.17</DynamoOutput>
<RevitVersion>2024</RevitVersion>
<DefineConstants>$(DefineConstants);R24</DefineConstants>
Expand Down
11 changes: 11 additions & 0 deletions OpenMEPRevit/Parameter/Parameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ private Parameter()
var SpecType = parameter.SpecType;
string StorageType = parameter.StorageType;
var UnitType = parameter.Unit;
#if R20 || R21 || R22 || R23
int Id = parameter.Id;
#else
long Id = parameter.Id;

#endif
object Value = parameter.Value;
bool IsReadOnly = parameter.IsReadOnly;
bool HasValue = parameter.HasValue;
Expand Down Expand Up @@ -169,7 +174,13 @@ private Parameter()
if (parameter == null) throw new ArgumentNullException(nameof(parameter));
if (elementid == null) throw new ArgumentNullException(nameof(elementid));
Autodesk.Revit.DB.Parameter? revitParameter = parameter?.ToRevitType();
#if R20 || R21 || R22 || R23
bool? flag = revitParameter?.CanBeAssociatedWithGlobalParameter(new ElementId((int) elementid));

#else
bool? flag = revitParameter?.CanBeAssociatedWithGlobalParameter(new ElementId((long)elementid));

#endif
return flag;
}

Expand Down
9 changes: 8 additions & 1 deletion OpenMEPRevit/Parameter/SharedParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,16 @@ FilteredElementCollector collector
#else
string? versionGuid = sharedParameterElement?.VersionGuid.ToString();
#endif
#if R20 || R21 || R22 || R23
int? groupId = sharedParameterElement?.GroupId.IntegerValue;
string? name = sharedParameterElement?.Name;
int? id = sharedParameterElement?.Id?.IntegerValue;

#else
long? groupId = sharedParameterElement?.GroupId.Value;
long? id = sharedParameterElement?.Id?.Value;

#endif
string? name = sharedParameterElement?.Name;
string? uniqueId = sharedParameterElement?.UniqueId;
bool? pinned = sharedParameterElement?.Pinned;
bool? shouldHideWhenNoValue = sharedParameterElement?.ShouldHideWhenNoValue();
Expand Down
12 changes: 12 additions & 0 deletions OpenMEPRevit/Utils/FamilyUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ public static void ConvertFamilyToFaceHostBased(Autodesk.Revit.DB.Document doc,i
{
using Transaction tran = new Autodesk.Revit.DB.Transaction (doc, "convert");
tran.Start();
#if R20 || R21 || R22 || R23
Autodesk.Revit.DB.FamilyUtils.ConvertFamilyToFaceHostBased(doc,new ElementId(familyId));

#else
Autodesk.Revit.DB.FamilyUtils.ConvertFamilyToFaceHostBased(doc, new ElementId((long)familyId));

#endif
tran.Commit();
}

Expand All @@ -50,7 +56,13 @@ public static bool FamilyCanConvertToFaceHostBased(Autodesk.Revit.DB.Document do
{
using Transaction tran = new Autodesk.Revit.DB.Transaction (doc, "convert");
tran.Start();
#if R20 || R21 || R22 || R23
bool result = Autodesk.Revit.DB.FamilyUtils.FamilyCanConvertToFaceHostBased(doc,new ElementId(familyId));

#else
bool result = Autodesk.Revit.DB.FamilyUtils.FamilyCanConvertToFaceHostBased(doc, new ElementId((long)familyId));

#endif
tran.Commit();
return result;
}
Expand Down
3 changes: 2 additions & 1 deletion OpenMEPViewExtension/OpenMEPViewExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public void Loaded(ViewLoadedParams viewLoadedParams)
// string direction = Regex.Replace(NodeEndPoint, pattern2, "_");
//MessageBox.Show(direction);
// Open a new window
string url = $"https://chuongmep.github.io/OpenMEP";///api/{MainNameSpace}.html#{direction}";
string url = $"https://chuongmep.github.io/OpenMEP";
//api/{MainNameSpace}.html#{direction}";
Process.Start(url);
};
#if R20 || R21
Expand Down

0 comments on commit d4da6c5

Please sign in to comment.