Hi @official.jaydeo
The class Autodesk.AdvanceSteel.Modelling.ScrewBoltPattern has a GetWeight() method.
This extends to all inheriting classes: AnchorPattern, CircleScrewBoltPattern, CountableScrewBoltPattern, FinitRectScrewBoltPattern,
InfinitMidScrewBoltPattern and InfinitRectScrewBoltPattern.
This method will return the weight for the whole set of Bolts/Screws/Nuts/Anchors.
Let's assume a bolt pattern was created like in this example:
FinitRectScrewBoltPattern boltPattern = null; // reference to the bolt pattern for later
// ...
using (DocumentAccess da = new DocumentAccess())
{
// build an "objects to connect" array
FilerObject[] objectsToConnect = new FilerObject[1];
objectsToConnect[0] = plate; // we assume an existing plate, that was previously created
// create a standard rectangular pattern set of bolts
boltPattern = Utilities.CreateFinitRectScrewBoltPattern(new Point3d(-100, -100, 0), new Point3d(100, 100, 0), new Vector3d(1, 0, 0), new Vector3d(0, 1, 0));
// connect the objects
boltPattern.Connect(objectsToConnect, AtomicElement.eAssemblyLocation.kOnSite);
// set a valid combination of properties
// check table "ScrewNew" from "AstorBase.mdb" for valid combinations
boltPattern.Standard = "14399-4";
boltPattern.Grade = "10.9";
boltPattern.BoltAssembly = "Mu2S";
boltPattern.ScrewDiameter = 16;
da.Commit();
}
GetWeight can be called like this, further divided by the number of screws to get the weight of each screw:
using(DocumentAccess da = new DocumentAccess())
{
// ...
double boltPatWeight = boltPattern.GetWeight() / 1000;
double singleWeight = boltPatWeight / boltPattern.NumberOfScrews;
// ...
}
If you want this split down even further, there is no specific API for it as of now.
Instead, you must add references to ASDataObjects.dll and ASRepository.dll and query the database in 2 steps:
The first step is to get the specific SetOfBolt for your ScrewBoltPattern. Replace with AnchorsName if it's an AnchorPattern instead.
using ASRepository;
using ASDataObjects.AstorBase;
using ASRepository.Criteria;
// ...
using(DocumentAccess da = new DocumentAccess())
{
// ...
SetOfBolt[] arrSetOfBolts = null;
using (var repo = RepositoryFactory.GetRepository<SetOfBolt>(eDatabase.kBase, -1))
{
var select = new SelByMultipleProps<SetOfBolt>(
new string[] { nameof(SetOfBolt.Standard), nameof(SetOfBolt.Material), nameof(SetOfBolt.Diameter) },
new object[] { boltPattern.Standard, boltPattern.Material, boltPattern.ScrewDiameter });
arrSetOfBolts = Enumerable.ToArray(repo.Select(select));
}
// ...
}
The second step is to iterate over the pattern's specific SetOfBolt and get the corresponding SetNutsBolt of every item, which is the data from the table in your screenshot.
SetOfBolt setOfBolt = arrSetOfBolts[0];
using (var repo = RepositoryFactory.GetRepository<SetNutsBolt>(eDatabase.kBase, -1))
{
for (int i = 1; i <= setOfBolt.Length; ++i)
{
var setOfBoltType = typeof(SetOfBolt);
string Standard = (string)setOfBoltType.GetProperty($"DIN{i}").GetValue(setOfBolt);
double Diameter =(double)setOfBoltType.GetProperty($"Diameter{i}__mm_").GetValue(setOfBolt);
string Material = (string)setOfBoltType.GetProperty($"Material{i}").GetValue(setOfBolt);
var select = new SelByMultipleProps<SetNutsBolt>(
new string[] { nameof(SetNutsBolt.Standard), nameof(SetNutsBolt.Material), nameof(SetNutsBolt.Diameter) },
new object[] { Standard, Material, Diameter });
SetNutsBolt[] partOfBolt = Enumerable.ToArray(repo.Select(select));
// THIS is the weight of each piece of a bolt
double partWeight = partOfBolt[0].Weight.GetValueOrDefault();
}
}