Beams and plates have processing features available.
This walkthrough will explain some of the processing features available for beams and plates in Advance Steel. Such features include holes, openings, shortenings, chamfers, fillets, notches, welding preparations and more. Most features are applicable to both beams and plates, however the Advance Steel API provides separate classes for them, such as ConnectionHoleBeam and ConnectionHolePlate. This tutorial will demonstrate how to use several of these features. Classes for features not covered in this tutorial can be found in the Autodesk.AdvanceSteel.Modelling namespace.
This tutorial assumes you have a new Advance Steel addon project with one class file that implements the IExtensionApplication interface.
Create a new class called CreateFeatures and add the following code:
Code Region: CreateFeatures command class |
using Autodesk.AdvanceSteel.CADAccess; using Autodesk.AdvanceSteel.DocumentManagement; using Autodesk.AdvanceSteel.Runtime; using Autodesk.AdvanceSteel.Geometry; using Autodesk.AdvanceSteel.Modelling; using Autodesk.AdvanceSteel.Profiles; using Autodesk.AdvanceSteel.ConstructionTypes; using Autodesk.AdvanceSteel.CADLink.Database; using System.Collections.Generic; using Autodesk.AdvanceSteel.Arrangement; using Autodesk.AdvanceSteel.Contours; namespace HelloWorld { class CreateFeatures { [CommandMethodAttribute("TEST_GROUP", "CreateFeatures", "CreateFeatures", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)] public void Create() { using (DocumentAccess da = new DocumentAccess(null, false)) { } } } } |
Note that this example uses all of the namespaces as the tutorial on model connections, plus a few more. Autodesk.AdvanceSteel.Arrangement and Autodesk.AdvanceSteel.Contours are namespaces that contain classes used when working with features.
Shortening
First, let us look at how to shorten a beam. Shortenings are cuts with an infinite plane that can be applied to a beam or plate, however, they can also extend the element if they are placed beyond the length of the beam or bounds of the plate.
Plates can be cut using the PlateFeatShortening class. This example will use the BeamShortening class to cut a beam. Beam shortenings can be defined by any plane except one that is parallel (or almost parallel) to the beam body. Similarly, plate shortenings can be defined by any plane that isn't parallel or nearly parallel to the plane of the plate.
Add a method to the CreateFeatures called ShortenBeam() as shown below.
Code Region: Shortening a beam |
private void ShortenBeam() { // Have the user select a beam to shorten ObjectId objId = UserInteraction.SelectObject(); Beam beam = DatabaseManager.Open(objId) as Beam; if (null != beam) { // first thing to do is add the feature to the parent // that sets owner and writes feature to db BeamShortening bs = new BeamShortening(Beam.eEnd.kEnd, 500); beam.AddFeature(bs); // once added to the beam, modify as needed bs.AngleOnZ = 45; } } |
The UserInteraction.SelectObject() method will prompt the user to select a beam or plate. Once selected, the code continues. In this case, it first ensures that the selected object was a beam.
When creating a new feature, it is necessary to add it to its parent object before setting its properties to avoid unexpected behavior. Adding the feature to the parent object (in this case a beam) sets the feature's owner and writes the feature to the dwg database.
In the code above, the beam is shortened 500 mm from the end of the beam. By changing the angle of the BeamShortening, the beam will be cut at a 45 degree angle.
Openings
Openings, or contours, can be added to beams and plates. Openings can be rectangular, round, or defined by a closed polygon. For beams, the opening class is called BeamMultiContourNotch . For plates, it is called PlateContourNotch.
Add a new method to the CreateFeatures class called CreateOpenings() and copy the code from below.
Code Region: Creating an opening in a beam |
private void CreateOpenings() { // Select one or more beams to create openings List<ObjectId> objIds = UserInteraction.SelectObjects(); foreach (ObjectId objId in objIds) { Beam beam = DatabaseManager.Open(objId) as Beam; if (null != beam) { // find the profile height of the beam to make a hole with a diameter half the height ProfileType profile = beam.GetProfType(); double width = profile.GetGeometricalData(ProfileType.eCommonData.kProfHeight); double holeRadius = width / 4; // create a circular opening in each selected beam along the beam's axis Vector3d vector = beam.GetPointAtStart() - beam.GetPointAtEnd(); BeamMultiContourNotch multiNotch = new BeamMultiContourNotch(beam, Beam.eEnd.kStart, beam.GetPointAtStart(400), new Vector3d(0, 1, 0), vector, holeRadius); beam.AddFeature(multiNotch); } } } |
This example allows the user to select multiple beams and then adds a circular opening 400 mm from the start of the beam along the beam's axis, with a radius depending on the height of the section profile. There are different constructors for BeamMultiContourNotch to allow creating rectangular or polygon openings, as well as circular openings.
Holes
Holes are a feature that can be added to beams (with ConnectionHoleBeam) and plates (with ConnectionHolePlate). Holes are laid out in a pattern, using an Arranger to define the location and number of holes. A separate Hole definition is provided to define the dimensions of the holes.
Add a new method to the class called CreateHolesInPlate() and include the following code:
Code Region: Creating holes in a plate |
private void CreateHolesInPlate() { // Create a plate and add holes to it Point3d plateOrig = Point3d.kOrigin; ; Plane platePlane = new Plane(plateOrig, Vector3d.kZAxis); Plate plate = new Plate(platePlane, plateOrig, 500, 500); plate.WriteToDb(); ConnectionHolePlate connectionHole = new ConnectionHolePlate(plate, new Matrix3d()); plate.AddFeature(connectionHole); // Create a rectangular arranger for the holes in a 3x2 pattern BoundedRectArranger arranger = new BoundedRectArranger(300, 200); arranger.Nx = 3; arranger.Ny = 2; connectionHole.Arranger = arranger; // Define the holes for the set connectionHole.Hole = new SlottedHole(20.0, 52.0, SlottedHole.eDirection.kXAxis); } |
Rather than getting a user-selected plate for this example, we will just create a new plate at the origin and add a pattern of 6 slotted holes in a 2x3 layout pattern. As before, the new feature is immediately added to the parent plate and then modifications are made to it. In this example, a BoundedRectArranger is used, but a CircleArranger or RectangularArranger could be used instead. Alternatives to a SlottedHole are the base class Hole, or ExtendedHole.
Putting it all together
Now we need to call the three methods in the Create() method. Edit the original Create() method to look like this:
Code Region: Creating multiple features |
public void Create() { using (DocumentAccess da = new DocumentAccess(null, false)) { ShortenBeam(); CreateOpenings(); CreateHolesInPlate(); da.Commit(); } } |
Prior to running this command in Advance Steel, you will need to add the necessary Informational Attribute directives in the AssemblyInfo.cs file as shown in the Hello World Walkthrough.
When this code is run, you will first be prompted to select a element to be shortened (be sure to select a beam or column) and then to select one or more beams (hit enter when finished selecting) in which to place openings, and finally it will create a new plate at the origin and add holes to it.