Advance Steel Forum
Welcome to Autodesk’s Advance Steel Forums. Share your knowledge, ask questions, and explore popular Advance Steel topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADVANCE STEEL API, READ ALL OBJECT AND THEIR PROPERTIES, TO CREATE BOM

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
official.jaydeo
1165 Views, 11 Replies

ADVANCE STEEL API, READ ALL OBJECT AND THEIR PROPERTIES, TO CREATE BOM

official.jaydeo
Enthusiast
Enthusiast

So I have advanced Steel model, classic problem where I don't want material take off by the type but I want for each part or it can be multiple instance of same type object. So inbuilt function of advanced steel option to create BOM/ metal takeoff , creates it with by type as a total, but I want for each instance.

 

1) i want loop through each object, i am not able to do that need help in this regard ****

2) read their properties 

3) then write all in excel (i can do)

0 Likes

ADVANCE STEEL API, READ ALL OBJECT AND THEIR PROPERTIES, TO CREATE BOM

So I have advanced Steel model, classic problem where I don't want material take off by the type but I want for each part or it can be multiple instance of same type object. So inbuilt function of advanced steel option to create BOM/ metal takeoff , creates it with by type as a total, but I want for each instance.

 

1) i want loop through each object, i am not able to do that need help in this regard ****

2) read their properties 

3) then write all in excel (i can do)

11 REPLIES 11
Message 2 of 12

george1985
Collaborator
Collaborator
Accepted solution

 

1) Obtain ids of all Advance Steel objects:
Autodesk.AdvanceSteel.CADAccess.DatabaseManager.GetModelObjectIds()

Get their objects:
Autodesk.AdvanceSteel.CADAccess.DatabaseManager.Open()
For this step, you would need to call upper Open method inside DocumentAccess. See the example in SDK documentation for NET API:

https://help.autodesk.com/view/ADSTPR/2022/ENU/?guid=GUID-19A366F0-C51F-45AB-AF0C-46E59ABFD284

2) Set up a debugger breakpoint in Visual Studio. Most properties are self-explanatory: ASobj.Material, Asobj.Coating, ASobj.Layer...

 

1) Obtain ids of all Advance Steel objects:
Autodesk.AdvanceSteel.CADAccess.DatabaseManager.GetModelObjectIds()

Get their objects:
Autodesk.AdvanceSteel.CADAccess.DatabaseManager.Open()
For this step, you would need to call upper Open method inside DocumentAccess. See the example in SDK documentation for NET API:

https://help.autodesk.com/view/ADSTPR/2022/ENU/?guid=GUID-19A366F0-C51F-45AB-AF0C-46E59ABFD284

2) Set up a debugger breakpoint in Visual Studio. Most properties are self-explanatory: ASobj.Material, Asobj.Coating, ASobj.Layer...

Message 3 of 12

official.jaydeo
Enthusiast
Enthusiast
how can i find washer / Nut in Autodesk Advance steel API .NET

I want to create very custom BOM where objects with same attributes are Counted , I have been succeeded, in finding all the objects types such as Beams, Plates, Bolt Patterns etc. but not able to do it with Washers and nuts

While Creating BOMs Manually you can find Washers and Nuts but not in API, 

Creating Manual BOM , is not an option as i want to sort them based on user attribute 

are washer/nut filer object , do they have objectId or no?

0 Likes

how can i find washer / Nut in Autodesk Advance steel API .NET

I want to create very custom BOM where objects with same attributes are Counted , I have been succeeded, in finding all the objects types such as Beams, Plates, Bolt Patterns etc. but not able to do it with Washers and nuts

While Creating BOMs Manually you can find Washers and Nuts but not in API, 

Creating Manual BOM , is not an option as i want to sort them based on user attribute 

are washer/nut filer object , do they have objectId or no?

Message 4 of 12

george1985
Collaborator
Collaborator

Hi @official.jaydeo ,
Yes, as far as I know, washers and nuts have no objectId.
You would have to calculate them based on the ".Assembly" property of the bolt pattern object.


Example:

"NaW" - 1 x nut, 1 x washer

"Na2W" - 1 x nut, 2 x washer

0 Likes

Hi @official.jaydeo ,
Yes, as far as I know, washers and nuts have no objectId.
You would have to calculate them based on the ".Assembly" property of the bolt pattern object.


Example:

"NaW" - 1 x nut, 1 x washer

"Na2W" - 1 x nut, 2 x washer

Message 5 of 12

official.jaydeo
Enthusiast
Enthusiast

I want to access their weight, is there any way we could know what washer /nut are used for BoltPatterns

officialjaydeo_0-1717013017010.png

@cristian.udreaBYPDW  @ChristianBlei @dragos.olaru @mihaido @NinovSM 

 

0 Likes

I want to access their weight, is there any way we could know what washer /nut are used for BoltPatterns

officialjaydeo_0-1717013017010.png

@cristian.udreaBYPDW  @ChristianBlei @dragos.olaru @mihaido @NinovSM 

 

Message 6 of 12

cristian.udreaBYPDW
Autodesk
Autodesk

Hi @official.jaydeo

 

The class Autodesk.AdvanceSteel.Modelling.ScrewBoltPattern has a GetWeight() method.
This extends to all inheriting classes:  AnchorPatternCircleScrewBoltPatternCountableScrewBoltPatternFinitRectScrewBoltPattern

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();
  }
}

 

 

Hi @official.jaydeo

 

The class Autodesk.AdvanceSteel.Modelling.ScrewBoltPattern has a GetWeight() method.
This extends to all inheriting classes:  AnchorPatternCircleScrewBoltPatternCountableScrewBoltPatternFinitRectScrewBoltPattern

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();
  }
}

 

 

Message 7 of 12

official.jaydeo
Enthusiast
Enthusiast

Sorry i did not get , how can i access Washer/Nut Properties from above code,

let me tell you what i know

I am getting all the Screw Bolts from project using this,

 

Autodesk.AdvanceSteel.CADLink.Database.ObjectId[] objectIds = null;
DatabaseManager.GetModelObjectIds(out objectIds);

 

then i am checking if it is BoltPattern

then i am getting screw properties

 

if (steelObject is Autodesk.AdvanceSteel.Modelling.BoltPattern BoltPattern1)
{
BoltPattern_Coll.Add(BoltPattern1);
}

 foreach (BoltPattern ty in BoltPattern_Coll)
 {
sw.WriteLine($"{0},{"Bolt " + ty.GetName(out v)},,
{UnitConverter1.ConvertMillimetersToFeetInches(ty.ScrewLength)},
{ConvertGramsToDecimalPounds(ty.GetWeight() * 
ty.NumberOfScrews).ToString("F2")},{ty.NumberOfScrews},{ty.Material} ,{ty.GetUserAttribute(UserAttributeint)}");
}

 



now how do i get type of washer used in this Bolt pattern and its weight, and all of it's Possible Properties....... @cristian.udreaBYPDW  @ChristianBlei @george1985 

 

0 Likes

Sorry i did not get , how can i access Washer/Nut Properties from above code,

let me tell you what i know

I am getting all the Screw Bolts from project using this,

 

Autodesk.AdvanceSteel.CADLink.Database.ObjectId[] objectIds = null;
DatabaseManager.GetModelObjectIds(out objectIds);

 

then i am checking if it is BoltPattern

then i am getting screw properties

 

if (steelObject is Autodesk.AdvanceSteel.Modelling.BoltPattern BoltPattern1)
{
BoltPattern_Coll.Add(BoltPattern1);
}

 foreach (BoltPattern ty in BoltPattern_Coll)
 {
sw.WriteLine($"{0},{"Bolt " + ty.GetName(out v)},,
{UnitConverter1.ConvertMillimetersToFeetInches(ty.ScrewLength)},
{ConvertGramsToDecimalPounds(ty.GetWeight() * 
ty.NumberOfScrews).ToString("F2")},{ty.NumberOfScrews},{ty.Material} ,{ty.GetUserAttribute(UserAttributeint)}");
}

 



now how do i get type of washer used in this Bolt pattern and its weight, and all of it's Possible Properties....... @cristian.udreaBYPDW  @ChristianBlei @george1985 

 

Message 8 of 12

cristian.udreaBYPDW
Autodesk
Autodesk
Accepted solution

Hi @official.jaydeo

Instead of Autodesk.AdvanceSteel.Modelling.BoltPattern please use the object class Autodesk.AdvanceSteel.Modelling.ScrewBoltPattern so that all the Bolt Pattern properties that are required to interrogate the database are available.

 

Then, to get the washer, nut, peg, etc. properties, adapt the code from my previous post to your particular situation.

 

AS.NET API does not publish methods or properties to get the Nut/Washer/Peg properties.
Instead the database must be interrogated to get these values.

 

The changed code would look similar to the following :

 

using ASRepository;
using ASDataObjects.AstorBase;
using ASRepository.Criteria;

/* ... */ 

if (steelObject is Autodesk.AdvanceSteel.Modelling.ScrewBoltPattern screwBoltPat)
{
  ScrewBoltPattern_Coll.Add(screwBoltPat);
}

/* ... */

foreach (ScrewBoltPattern screwBoltPat in ScrewBoltPattern_Coll)
{
  // Get the representation of a screw or bolt in the database
  SetOfBolt[] arrSetOfBolts = null;
  using (var repo = RepositoryFactory.GetRepository<SetOfBolt>(eDatabase.kBase, -1))
  {
    var dbSelect = new SelByMultipleProps<SetOfBolt>(
          new string[] { nameof(SetOfBolt.Standard), nameof(SetOfBolt.Material), nameof(SetOfBolt.Diameter) },
          new object[] { screwBoltPat.Standard, screwBoltPat.Material, screwBoltPat.ScrewDiameter });

    arrSetOfBolts = Enumerable.ToArray(repo.Select(dbSelect));
  }

  // Iterate the set of Peg/Nut/Washer parts
  SetOfBolt setOfBolt = arrSetOfBolts[0];
  using (var repo = RepositoryFactory.GetRepository<SetNutsBolt>(eDatabase.kBase, -1))
  {
    // setOfBolt.Length is how many parts there are to a bolt, such as a nut a peg or a washer
    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);

      // Interrogate the database again, this time for each individual part of the bolt
      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));
      // partOfBolt[0] might be a nut, a peg or a washer depending on the Type property
      // 1 is for Nut, 2 is for Washer, 3 is for Peg
      int partType = partOfBolt[0].Type.GetValueOrDefault();
      
      // This is the weight of each piece of a bolt or screw (e.g. a nut or a washer)
      double partWeight = partOfBolt[0].Weight.GetValueOrDefault();
      // or other properties like
      double partHeight = partOfBolt[0].Height.GetValueOrDefault();
      int partNocorners = partOfBolt[0].NumberOfCorners.GetValueOrDefault();
      // etc.
    }
  }
}

 

Hi @official.jaydeo

Instead of Autodesk.AdvanceSteel.Modelling.BoltPattern please use the object class Autodesk.AdvanceSteel.Modelling.ScrewBoltPattern so that all the Bolt Pattern properties that are required to interrogate the database are available.

 

Then, to get the washer, nut, peg, etc. properties, adapt the code from my previous post to your particular situation.

 

AS.NET API does not publish methods or properties to get the Nut/Washer/Peg properties.
Instead the database must be interrogated to get these values.

 

The changed code would look similar to the following :

 

using ASRepository;
using ASDataObjects.AstorBase;
using ASRepository.Criteria;

/* ... */ 

if (steelObject is Autodesk.AdvanceSteel.Modelling.ScrewBoltPattern screwBoltPat)
{
  ScrewBoltPattern_Coll.Add(screwBoltPat);
}

/* ... */

foreach (ScrewBoltPattern screwBoltPat in ScrewBoltPattern_Coll)
{
  // Get the representation of a screw or bolt in the database
  SetOfBolt[] arrSetOfBolts = null;
  using (var repo = RepositoryFactory.GetRepository<SetOfBolt>(eDatabase.kBase, -1))
  {
    var dbSelect = new SelByMultipleProps<SetOfBolt>(
          new string[] { nameof(SetOfBolt.Standard), nameof(SetOfBolt.Material), nameof(SetOfBolt.Diameter) },
          new object[] { screwBoltPat.Standard, screwBoltPat.Material, screwBoltPat.ScrewDiameter });

    arrSetOfBolts = Enumerable.ToArray(repo.Select(dbSelect));
  }

  // Iterate the set of Peg/Nut/Washer parts
  SetOfBolt setOfBolt = arrSetOfBolts[0];
  using (var repo = RepositoryFactory.GetRepository<SetNutsBolt>(eDatabase.kBase, -1))
  {
    // setOfBolt.Length is how many parts there are to a bolt, such as a nut a peg or a washer
    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);

      // Interrogate the database again, this time for each individual part of the bolt
      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));
      // partOfBolt[0] might be a nut, a peg or a washer depending on the Type property
      // 1 is for Nut, 2 is for Washer, 3 is for Peg
      int partType = partOfBolt[0].Type.GetValueOrDefault();
      
      // This is the weight of each piece of a bolt or screw (e.g. a nut or a washer)
      double partWeight = partOfBolt[0].Weight.GetValueOrDefault();
      // or other properties like
      double partHeight = partOfBolt[0].Height.GetValueOrDefault();
      int partNocorners = partOfBolt[0].NumberOfCorners.GetValueOrDefault();
      // etc.
    }
  }
}

 

Message 9 of 12

official.jaydeo
Enthusiast
Enthusiast

Thanks! 

with few Modifications it worked.

 

0 Likes

Thanks! 

with few Modifications it worked.

 

Message 10 of 12

official.jaydeo
Enthusiast
Enthusiast

i was able to find bolts in database using setBolts, how do i find Anchors? i could not find any class

0 Likes

i was able to find bolts in database using setBolts, how do i find Anchors? i could not find any class

Message 11 of 12

cristian.udreaBYPDW
Autodesk
Autodesk
Accepted solution

@official.jaydeo For Anchors the same information (Nuts and Washers) can be found in the structure AnchorsName.

The code to access Anchor information is similar to the one used to access the Bolts information, with a few class and property changes. The object class is Autodesk.AdvanceSteel.Modelling.AnchorPattern and the changed code would look similar to the following:

 

using ASRepository;
using ASDataObjects.AstorBase;
using ASRepository.Criteria;

/* ... */ 

if (steelObject is Autodesk.AdvanceSteel.Modelling.AnchorPattern anchorPat)
{
  AnchorPattern_Coll.Add(anchorPat);
}

/* ... */

foreach (AnchorPattern anchorPat in AnchorPattern_Coll)
{
      // Get the Anchor definition
      AnchorsName[] arrAnchorDefs = null;
      using (var repo = RepositoryFactory.GetRepository<AnchorsName>(eDatabase.kBase, -1))
      {
         var selAnchorDef = new SelByMultipleProps<AnchorsName>(
               new string[] { nameof(AnchorsName.Standard), nameof(AnchorsName.MaterialKey), nameof(AnchorsName.Diameter), nameof(AnchorsName.SetName) },
               new object[] { anchorPat.Standard, anchorPat.Material, anchorPat.ScrewDiameter, anchorPat.BoltAssembly });
         arrAnchorDefs = Enumerable.ToArray(repo.Select(selAnchorDef));
      }

      // Iterate the set of Nut/Washer parts of the Anchor
      AnchorsName anchorParts = arrAnchorDefs[0];
      using (var repo = RepositoryFactory.GetRepository<SetNutsBolt>(eDatabase.kBase, -1))
      {
         // anchorParts.Length is how many parts there are to an anchor, such as a nut or a washer
         for (int i = 1; i <= anchorParts.NumItems; ++i)
         {
            var anchorDefType = typeof(AnchorsName);
            string Standard = (string)anchorDefType.GetProperty($"DIN{i}").GetValue(anchorParts);
            double Diameter = (double)anchorDefType.GetProperty($"Diameter{i}").GetValue(anchorParts);
            string Material = (string)anchorDefType.GetProperty($"Material{i}").GetValue(anchorParts);

            // Interrogate the database again, this time for each individual part of the bolt
            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));
            // partOfBolt[0] might be a nut or a washer depending on the Type property
            // 1 is for Nut, 2 is for Washer
            int partType = partOfBolt[0].Type.GetValueOrDefault();

            // This is the weight of each piece of an anchor (e.g. a nut or a washer)
            double partWeight = partOfBolt[0].Weight.GetValueOrDefault();
            // or other properties like
            double partHeight = partOfBolt[0].Height.GetValueOrDefault();
            int partNocorners = partOfBolt[0].NumberOfCorners.GetValueOrDefault();
            // etc.
         }
      }
   }
}

 

The different anchor definitions for each one specific anchor type can be found in the structure AnchorsDefinition, based on AnchorsName.ID and accessed similar to the following:

 

AnchorsDefinition[] anchorsDefinitions = null;
using (var repo = RepositoryFactory.GetRepository<AnchorsDefinition>(eDatabase.kBase, -1))
{
   var selAssy = new SelByPropValue<AnchorsDefinition, int>(nameof(AnchorsDefinition.AnchorID), anchorParts.ID);
   anchorsDefinitions = Enumerable.ToArray(repo.Select(selAssy));
}

 

If the database query succeeds, anchorsDefinitions now contains all the different anchor definitions for this one specific anchor type similar to the Database Management tool.

@official.jaydeo For Anchors the same information (Nuts and Washers) can be found in the structure AnchorsName.

The code to access Anchor information is similar to the one used to access the Bolts information, with a few class and property changes. The object class is Autodesk.AdvanceSteel.Modelling.AnchorPattern and the changed code would look similar to the following:

 

using ASRepository;
using ASDataObjects.AstorBase;
using ASRepository.Criteria;

/* ... */ 

if (steelObject is Autodesk.AdvanceSteel.Modelling.AnchorPattern anchorPat)
{
  AnchorPattern_Coll.Add(anchorPat);
}

/* ... */

foreach (AnchorPattern anchorPat in AnchorPattern_Coll)
{
      // Get the Anchor definition
      AnchorsName[] arrAnchorDefs = null;
      using (var repo = RepositoryFactory.GetRepository<AnchorsName>(eDatabase.kBase, -1))
      {
         var selAnchorDef = new SelByMultipleProps<AnchorsName>(
               new string[] { nameof(AnchorsName.Standard), nameof(AnchorsName.MaterialKey), nameof(AnchorsName.Diameter), nameof(AnchorsName.SetName) },
               new object[] { anchorPat.Standard, anchorPat.Material, anchorPat.ScrewDiameter, anchorPat.BoltAssembly });
         arrAnchorDefs = Enumerable.ToArray(repo.Select(selAnchorDef));
      }

      // Iterate the set of Nut/Washer parts of the Anchor
      AnchorsName anchorParts = arrAnchorDefs[0];
      using (var repo = RepositoryFactory.GetRepository<SetNutsBolt>(eDatabase.kBase, -1))
      {
         // anchorParts.Length is how many parts there are to an anchor, such as a nut or a washer
         for (int i = 1; i <= anchorParts.NumItems; ++i)
         {
            var anchorDefType = typeof(AnchorsName);
            string Standard = (string)anchorDefType.GetProperty($"DIN{i}").GetValue(anchorParts);
            double Diameter = (double)anchorDefType.GetProperty($"Diameter{i}").GetValue(anchorParts);
            string Material = (string)anchorDefType.GetProperty($"Material{i}").GetValue(anchorParts);

            // Interrogate the database again, this time for each individual part of the bolt
            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));
            // partOfBolt[0] might be a nut or a washer depending on the Type property
            // 1 is for Nut, 2 is for Washer
            int partType = partOfBolt[0].Type.GetValueOrDefault();

            // This is the weight of each piece of an anchor (e.g. a nut or a washer)
            double partWeight = partOfBolt[0].Weight.GetValueOrDefault();
            // or other properties like
            double partHeight = partOfBolt[0].Height.GetValueOrDefault();
            int partNocorners = partOfBolt[0].NumberOfCorners.GetValueOrDefault();
            // etc.
         }
      }
   }
}

 

The different anchor definitions for each one specific anchor type can be found in the structure AnchorsDefinition, based on AnchorsName.ID and accessed similar to the following:

 

AnchorsDefinition[] anchorsDefinitions = null;
using (var repo = RepositoryFactory.GetRepository<AnchorsDefinition>(eDatabase.kBase, -1))
{
   var selAssy = new SelByPropValue<AnchorsDefinition, int>(nameof(AnchorsDefinition.AnchorID), anchorParts.ID);
   anchorsDefinitions = Enumerable.ToArray(repo.Select(selAssy));
}

 

If the database query succeeds, anchorsDefinitions now contains all the different anchor definitions for this one specific anchor type similar to the Database Management tool.

Message 12 of 12

official.jaydeo
Enthusiast
Enthusiast

Many Thanks, few updates and this works fine!

0 Likes

Many Thanks, few updates and this works fine!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report