Skip to content

Commit

Permalink
feat(AdvanceSteel): Structure and groups (#2817)
Browse files Browse the repository at this point in the history
  • Loading branch information
teocomi authored Aug 1, 2023
2 parents dde8430 + e76f667 commit a669b50
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public Base ConvertASToSpeckle(DBObject @object, ApplicationObject reportObj, Li
@base["area unit"] = UnitArea;
@base["volume unit"] = UnitVolume;

var objectHandleHierarchy = StructureUtils.GetObjectHandleHierarchy();
if (objectHandleHierarchy.ContainsKey(filerObject.Handle))
{
@base["hierarchy"] = objectHandleHierarchy[filerObject.Handle];
}

return @base;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ public partial class ConverterAutocadCivil
{
private IAsteelObject FilerObjectToSpeckle(ASPlate plate, List<string> notes)
{
AsteelSlab asteelSlab = new AsteelSlab();
AsteelPlate asteelPlate = new AsteelPlate();

plate.GetBaseContourPolygon(0, out ASPoint3d[] ptsContour);

asteelSlab.outline = PolycurveToSpeckle(ptsContour);
asteelPlate.outline = PolycurveToSpeckle(ptsContour);

asteelSlab.area = plate.GetPaintArea();
asteelPlate.area = plate.GetPaintArea();

SetDisplayValue(asteelSlab, plate);
SetDisplayValue(asteelPlate, plate);

return asteelSlab;
return asteelPlate;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public partial class ConverterAutocadCivil
{
private IAsteelObject FilerObjectToSpeckle(ASSlab slab, List<string> notes)
{
AsteelGrating asteelGrating = new AsteelGrating();
AsteelSlab asteelSlab = new AsteelSlab();

SetDisplayValue(asteelGrating, slab);
SetDisplayValue(asteelSlab, slab);

return asteelGrating;
return asteelSlab;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override Dictionary<string, ASProperty> BuildedPropertyList()
InsertProperty(dictionary, "item number", nameof(AtomicElement.ItemNumber));
InsertProperty(dictionary, "specific gravity", nameof(AtomicElement.SpecificGravity));
InsertProperty(dictionary, "coating", nameof(AtomicElement.Coating));
InsertProperty(dictionary, "number of holes", nameof(AtomicElement.NumberOfHoles));
InsertProperty(dictionary, "holes number", nameof(AtomicElement.NumberOfHoles));
InsertProperty(dictionary, "is attached part", nameof(AtomicElement.IsAttachedPart));
InsertProperty(dictionary, "is main part", nameof(AtomicElement.IsMainPart));
InsertProperty(dictionary, "main part prefix", nameof(AtomicElement.MainPartPrefix));
Expand All @@ -63,6 +63,7 @@ public override Dictionary<string, ASProperty> BuildedPropertyList()
InsertProperty(dictionary, "model quantity", nameof(AtomicElement.GetQuantityInModel));
InsertProperty(dictionary, "singlePart position", nameof(AtomicElement.GetSinglePartPositionNumber));
InsertProperty(dictionary, "features number", nameof(AtomicElement.NumFeatures));
InsertCustomProperty(dictionary, "cuts number", nameof(AtomicElementProperties.GetCutsNumber), null);
InsertCustomProperty(dictionary, "balance point", nameof(AtomicElementProperties.GetBalancePoint), null);
InsertCustomProperty(dictionary, "holes", nameof(AtomicElementProperties.GetHoles), null, eUnitType.kDistance);
InsertCustomProperty(dictionary, "numbering - valid single part", nameof(AtomicElementProperties.HasValidSPNumber), null);
Expand All @@ -71,6 +72,11 @@ public override Dictionary<string, ASProperty> BuildedPropertyList()
return dictionary;
}

private static double GetCutsNumber(AtomicElement atomicElement)
{
return atomicElement.NumFeatures() - atomicElement.NumberOfHoles;
}

private static Point3d GetBalancePoint(AtomicElement atomicElement)
{
//it's necessary round the balance point because it has different returns at the last decimals
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#if ADVANCESTEEL2023
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AdvanceSteel.BuildingStructure;
using Autodesk.AdvanceSteel.CADAccess;
using Autodesk.AutoCAD.DatabaseServices;
using ASObjectId = Autodesk.AdvanceSteel.CADLink.Database.ObjectId;

namespace Objects.Converter.AutocadCivil;

internal static class StructureUtils
{
private static Dictionary<string, BuildingStructureObject> GetStructures()
{
Dictionary<string, BuildingStructureObject> dictionary = new Dictionary<string, BuildingStructureObject>();

BuildingStructureManager buildStructMan = BuildingStructureManager.getBuildingStructureManager();
// get the list objects from the manager
BuildingStructureManagerListObject buildStructManListObject = buildStructMan.ListObject;
// get all of the structures in the BuildingStructureManagerListObject
List<BuildingStructureObject> bsoList = buildStructManListObject.Structures;

foreach (BuildingStructureObject currBSO in bsoList)
{
// building structure objects have a name
string name = buildStructManListObject.GetStructureName(currBSO);

if (dictionary.ContainsKey(name))
continue;

dictionary.Add(name, currBSO);
}

return dictionary;
}

private static Dictionary<string, ObjectsGroup> GetObjectsGroup(BuildingStructureObject structure)
{
Dictionary<string, ObjectsGroup> dictionaryGroup = new Dictionary<string, ObjectsGroup>();

BuildingStructureTreeObject groupsTreeObject = structure.GroupsTreeObject;

foreach (BuildingStructureItem currentItem in groupsTreeObject.StructureItems)
{
if (!(currentItem is ObjectsGroup objectsGroup))
continue;

BuildingStructureTreeObject parent = objectsGroup.Parent;
string nameGroup = parent.GetStructureItemName(objectsGroup);

dictionaryGroup.Add(nameGroup, objectsGroup);
}

return dictionaryGroup;
}

private static Dictionary<string, Dictionary<string, List<string>>> objectHandleHierarch;

public static Dictionary<string, Dictionary<string, List<string>>> GetObjectHandleHierarchy()
{
if(objectHandleHierarch == null)
{
objectHandleHierarch = GetObjectHandleHierarchyIntern();
}

return objectHandleHierarch;
}

private static Dictionary<string, Dictionary<string, List<string>>> GetObjectHandleHierarchyIntern()
{
Dictionary<string, Dictionary<string, List<string>>> dictionaryHierarchy = new Dictionary<string, Dictionary<string, List<string>>>();

var structures = GetStructures();

foreach (var structure in structures)
{
var groups = GetObjectsGroup(structure.Value);

foreach (var itemGroup in groups)
{
IEnumerable<string> listHandle = itemGroup.Value.getObjectsIDs().Select(x => new ObjectId(x.AsOldId()).Handle.ToString()).Where(x => !x.Equals("0"));

foreach (var handle in listHandle)
{
Dictionary<string, List<string>> dictionaryStructureGroup;
if (dictionaryHierarchy.ContainsKey(handle))
{
dictionaryStructureGroup = dictionaryHierarchy[handle];
}
else
{
dictionaryStructureGroup = new Dictionary<string, List<string>>();
dictionaryHierarchy.Add(handle, dictionaryStructureGroup);
}

List<string> listGroup = null;

if (dictionaryStructureGroup.ContainsKey(structure.Key))
{
listGroup = dictionaryStructureGroup[structure.Key];
}
else
{
listGroup = new List<string>();
dictionaryStructureGroup.Add(structure.Key, listGroup);
}

listGroup.Add(itemGroup.Key);

}//foreach handle

}//foreach group

}//foreach structure

return dictionaryHierarchy;
}

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

#if ADVANCESTEEL2023
using Autodesk.AdvanceSteel.DocumentManagement;
using static Autodesk.AdvanceSteel.DotNetRoots.Units.Unit;
#endif

#if CIVIL2021 || CIVIL2022 || CIVIL2023 || CIVIL2024
using Autodesk.Aec.ApplicationServices;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<Compile Include="$(MSBuildThisFileDirectory)AdvanceSteel\Properties\PropertySets\MainAliasProperties.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AdvanceSteel\Properties\PropertySets\PolybeamProperties.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AdvanceSteel\Properties\PropertySets\AtomicElementProperties.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AdvanceSteel\Properties\StructureUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Converter.AutocadCivil.Utils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AdvanceSteel\ConverterAutocadCivil.AdvanceSteel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AdvanceSteel\ConverterAutocadCivil.DxfNames.cs" />
Expand Down

0 comments on commit a669b50

Please sign in to comment.