Skip to content

Commit

Permalink
Add predeftypes for Point/Line/Surface supports
Browse files Browse the repository at this point in the history
  • Loading branch information
andosca committed Jan 29, 2021
1 parent ceaa82e commit 771b96a
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/LibraryItems/ConnectionTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ namespace FemDesign.LibraryItems
public class PointConnectionTypes
{
[XmlElement("predefined_type", Order = 1)]
public Releases.RigidityDataLibType2[] PredefinedTypes { get; set; }
public List<Releases.RigidityDataLibType2> PredefinedTypes { get; set; }
}

[System.Serializable]
[IsVisibleInDynamoLibrary(false)]
public class PointSupportGroupTypes
{
[XmlElement("predefined_type", Order = 1)]
public Releases.RigidityDataLibType2[] PredefinedTypes { get; set; }
public List<Releases.RigidityDataLibType2> PredefinedTypes { get; set; }
}

[System.Serializable]
Expand All @@ -38,22 +38,22 @@ public class LineConnectionTypes
public class LineSupportGroupTypes
{
[XmlElement("predefined_type", Order = 1)]
public Releases.RigidityDataLibType2[] PredefinedTypes { get; set; }
public List<Releases.RigidityDataLibType2> PredefinedTypes { get; set; }
}

[System.Serializable]
[IsVisibleInDynamoLibrary(false)]
public class SurfaceConnectionTypes
{
[XmlElement("predefined_type", Order = 1)]
public Releases.RigidityDataLibType1[] PredefinedTypes { get; set; }
public List<Releases.RigidityDataLibType1> PredefinedTypes { get; set; }
}

[System.Serializable]
[IsVisibleInDynamoLibrary(false)]
public class SurfaceSupportTypes
{
[XmlElement("predefined_type", Order = 1)]
public Releases.RigidityDataLibType1[] PredefinedTypes { get; set; }
public List<Releases.RigidityDataLibType1> PredefinedTypes { get; set; }
}
}
115 changes: 114 additions & 1 deletion src/Model/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,43 @@ private void AddPointSupport(Supports.PointSupport obj, bool overwrite)

// add obj
this.Entities.Supports.PointSupport.Add(obj);

// add predefined rigidity
if (obj.Group.PredefRigidity != null)
{
this.AddPointSupportGroupLibItem(obj.Group.PredefRigidity, overwrite);
}
}

/// <summary>
/// Add predefined point support rigidity to model
/// </summary>
private void AddPointSupportGroupLibItem(Releases.RigidityDataLibType2 obj, bool overwrite)
{
// if null create new element
if (this.PointSupportGroupTypes == null)
{
this.PointSupportGroupTypes = new LibraryItems.PointSupportGroupTypes();
this.PointSupportGroupTypes.PredefinedTypes = new List<Releases.RigidityDataLibType2>();
}

// in model?
bool inModel = this.PointSupportGroupTypes.PredefinedTypes.Any(x => x.Guid == obj.Guid);

// in model, don't overwrite
if (inModel && !overwrite)
{
throw new System.ArgumentException($"{obj.GetType().FullName} with guid: {obj.Guid} has already been added to model. Are you adding the same element twice?");
}

// in model, overwrite
else if (inModel && overwrite)
{
this.PointSupportGroupTypes.PredefinedTypes.RemoveAll(x => x.Guid == obj.Guid);
}

// add lib item
this.PointSupportGroupTypes.PredefinedTypes.Add(obj);
}

/// <summary>
Expand All @@ -1504,6 +1541,8 @@ private bool PointSupportInModel(Supports.PointSupport obj)
return false;
}



/// <summary>
/// Add LineSupport to Model.
/// </summary>
Expand All @@ -1526,6 +1565,12 @@ private void AddLineSupport(Supports.LineSupport obj, bool overwrite)

// add obj
this.Entities.Supports.LineSupport.Add(obj);

// add lib item
if (obj.Group.PredefRigidity != null)
{
this.AddLineSupportGroupLibItem(obj.Group.PredefRigidity, overwrite);
}
}

/// <summary>
Expand All @@ -1543,6 +1588,37 @@ private bool LineSupportInModel(Supports.LineSupport obj)
return false;
}

/// <summary>
/// Add predefined line support rigidity to model
/// </summary>
private void AddLineSupportGroupLibItem(Releases.RigidityDataLibType2 obj, bool overwrite)
{
// if null create new element
if (this.LineSupportGroupTypes == null)
{
this.LineSupportGroupTypes = new LibraryItems.LineSupportGroupTypes();
this.LineSupportGroupTypes.PredefinedTypes = new List<Releases.RigidityDataLibType2>();
}

// in model?
bool inModel = this.LineSupportGroupTypes.PredefinedTypes.Any(x => x.Guid == obj.Guid);

// in model, don't overwrite
if (inModel && !overwrite)
{
throw new System.ArgumentException($"{obj.GetType().FullName} with guid: {obj.Guid} has already been added to model. Are you adding the same element twice?");
}

// in model, overwrite
else if (inModel && overwrite)
{
this.LineSupportGroupTypes.PredefinedTypes.RemoveAll(x => x.Guid == obj.Guid);
}

// add obj
this.LineSupportGroupTypes.PredefinedTypes.Add(obj);
}

/// <summary>
/// Add SurfaceSupport to Model.
/// </summary>
Expand All @@ -1565,10 +1641,16 @@ private void AddSurfaceSupport(Supports.SurfaceSupport obj, bool overwrite)

// add obj
this.Entities.Supports.SurfaceSupport.Add(obj);

// add lib item
if (obj.PredefRigidity != null)
{
this.AddSurfaceSupportLibItem(obj.PredefRigidity, overwrite);
}
}

/// <summary>
/// Check if LineSupport in Model.
/// Check if SurfaceSupport in Model.
/// </summary>
private bool SurfaceSupportInModel(Supports.SurfaceSupport obj)
{
Expand All @@ -1582,6 +1664,37 @@ private bool SurfaceSupportInModel(Supports.SurfaceSupport obj)
return false;
}

/// <summary>
/// Add predefined surface support rigidity to model
/// </summary>
private void AddSurfaceSupportLibItem(Releases.RigidityDataLibType1 obj, bool overwrite)
{
// if null create new element
if (this.SurfaceSupportTypes == null)
{
this.SurfaceSupportTypes = new LibraryItems.SurfaceSupportTypes();
this.SurfaceSupportTypes.PredefinedTypes = new List<Releases.RigidityDataLibType1>();
}

// in model?
bool inModel = this.SurfaceSupportTypes.PredefinedTypes.Any(x => x.Guid == obj.Guid);

// in model, don't overwrite
if (inModel && !overwrite)
{
throw new System.ArgumentException($"{obj.GetType().FullName} with guid: {obj.Guid} has already been added to model. Are you adding the same element twice?");
}

// in model, overwrite
else if (inModel && overwrite)
{
this.SurfaceSupportTypes.PredefinedTypes.RemoveAll(x => x.Guid == obj.Guid);
}

// add obj
this.SurfaceSupportTypes.PredefinedTypes.Add(obj);
}

/// <summary>
/// Add Material to Model.
/// </summary>
Expand Down

0 comments on commit 771b96a

Please sign in to comment.