Share
 
 

IRule Interface

To create custom connections for Advance Steel, implement the IRule interface.

The IRule interface is defined in the ASObjectsMgd.dll library. It has methods and properties required for defining an Advance steel connection.

JointId property

This property provides an ObjectId to identify the connection. A simple auto-implementation is all that is needed for this property.

Code Region: Implement JointId

public Autodesk.AdvanceSteel.CADLink.Database.ObjectId JointId { get; set; }

Query() method

This is the method where the connection defines its input elements, which can be any Autodesk.AdvanceSteel.CADAccess.FilerObject such as beams, plates, or a point. The Query method takes an IUI input parameter which can be used to let the user select the input objects. The input objects should be added to an IJoint from the Query method, to be referenced later when the connection is created.

In the following example, the user is prompted to select a plate and beam which will be used in the connection. The FilerObjects are then set in the IJoint using the setInputObjects() method. Note that the IJoint is referenced by the JointId.

Code Region: Implement Query

public void Query(IUI ui)
{
    eUIErrorCodes errCodePlate, errCodeBeam;

    FilerObject beam, mainplate;
    mainplate = ui.AcquireSingleObjectWithKeywords(90279, out errCodePlate); // select main plate
    beam = ui.AcquireSingleObjectWithKeywords(90284, out errCodeBeam);      // select connecting object

    if (errCodePlate == eUIErrorCodes.kUINormal && errCodeBeam == eUIErrorCodes.kUINormal)
    {
        IJoint joint = DatabaseManager.Open(JointId) as IJoint;
        if (null != joint)
        {
            joint.setInputObjects(new FilerObject[] { mainplate, beam }, new int[] { 1, 1 });
        }
    }
}

GetTableName() method

This is an optional method. It is useful if a table is defined inside the AstorRules database that will store predefined values for your connection. If not needed, return an empty string.

Code Region: Implement GetTableName

public string GetTableName()
{
	return "";
}

GetRulePages() method

This method is where the user-modifiable parameters that control the connection behavior are defined. This method has a IRuleUIBuilder input parameter which provides methods to add user controls to the rule pages UI. You can define pages and then you can define controls for each page. Controls include simple controls such as text boxes and check boxes, as well as more complex controls such as bolt selectors or custom selectors. (Selectors are drop down controls with 2 or more options.)

Note that the names of the controls defined for the rules pages should be identical to the names of the parameters used in the Save() and Load() methods (see below).

The following code creates a single page with multiple parameters for the user to define how the connection will be created.

Code Region: Implement GetRulePages

public void GetRulePages(IRuleUIBuilder builder)
{
    builder.SheetDimension = IRuleUIBuilder.eSheetDimension.kStandard;
            
    int pageNo = builder.BuildRulePage(89954, -1, 60601); // no group, page title and bitmap are copied from an ApexAntiSag page
            
    builder.AddSelectorCustom(pageNo, "_connector", "_connector", typeof(int), new string[] { "Bolt", "Anchor", "Hole" });
    builder.AddSelectorCustom(pageNo, "_reference", "_reference", typeof(int), new string[] { "Intersection area", "Plate" });
    builder.AddSelectorCustom(pageNo, "_layout", "_layout", typeof(int), new string[] { "Centered", "Edge" });

    builder.AddTextBox(pageNo, "_numBoltsXDir", "_numBoltsXDir", typeof(int));
    builder.AddTextBox(pageNo, "_numBoltsYDir", "_numBoltsYDir", typeof(int));
    builder.AddTextBox(pageNo, "_intermediateDistX", "_intermediateDistX", typeof(double), Autodesk.AdvanceSteel.DotNetRoots.Units.Unit.eUnitType.kDistance);
    builder.AddTextBox(pageNo, "_intermediateDistY", "_intermediateDistY", typeof(double), Autodesk.AdvanceSteel.DotNetRoots.Units.Unit.eUnitType.kDistance);
    builder.AddTextBox(pageNo, "_offsetX", "_offsetX", typeof(double), Autodesk.AdvanceSteel.DotNetRoots.Units.Unit.eUnitType.kDistance);
    builder.AddTextBox(pageNo, "_offsetY", "_offsetY", typeof(double), Autodesk.AdvanceSteel.DotNetRoots.Units.Unit.eUnitType.kDistance);

    builder.AddTextBox(pageNo, "_edge1", "_edge1", typeof(double), Autodesk.AdvanceSteel.DotNetRoots.Units.Unit.eUnitType.kDistance);
    builder.AddTextBox(pageNo, "_edge2", "_edge2", typeof(double), Autodesk.AdvanceSteel.DotNetRoots.Units.Unit.eUnitType.kDistance);
    builder.AddTextBox(pageNo, "_edge3", "_edge3", typeof(double), Autodesk.AdvanceSteel.DotNetRoots.Units.Unit.eUnitType.kDistance);
    builder.AddTextBox(pageNo, "_edge4", "_edge4", typeof(double), Autodesk.AdvanceSteel.DotNetRoots.Units.Unit.eUnitType.kDistance);

    builder.AddSelectorCustom(pageNo, "_stagger", "_stagger", typeof(int), new string[] { "One direction", "Other direction" });
    builder.AddTextBox(pageNo, "_staggerDist", "_staggerDist", typeof(double), Autodesk.AdvanceSteel.DotNetRoots.Units.Unit.eUnitType.kDistance);

}

Save() and Load() methods

These methods are used to save and load parameters for the connection definition that are shown in the rules pages. The values saved and loaded through these interface methods are the values associated with rule pages UI and the names should match the names used in the IRuleUIBuilder interface of GetRulePages(). The values are read and written to an IFiler object.

In the code below, the values saved and read are coming from member variables of the class implementing the IRule interface.

Code Region: Implement Save and Load

public void Save(IFiler filer)
{
    filer.WriteVersion(1);

    filer.WriteItem(_numBoltsXDir, "_numBoltsXDir");
    filer.WriteItem(_numBoltsYDir, "_numBoltsYDir");
    filer.WriteItem(_intermediateDistX, "_intermediateDistX");
    filer.WriteItem(_intermediateDistY, "_intermediateDistY");
    filer.WriteItem(_offsetX, "_offsetX");
    filer.WriteItem(_offsetY, "_offsetY");
    filer.WriteItem(_staggerDist, "_staggerDist");

    filer.WriteItem(_edge1, "_edge1");
    filer.WriteItem(_edge2, "_edge2");
    filer.WriteItem(_edge3, "_edge3");
    filer.WriteItem(_edge4, "_edge4");

    filer.WriteItem(_layout, "_layout");
    filer.WriteItem(_connector, "_connector");
    filer.WriteItem(_reference, "_reference");
    filer.WriteItem(_stagger, "_stagger");
}

public void Load(IFiler filer)
{
    _numBoltsXDir = (int)filer.ReadItem("_numBoltsXDir");
    _numBoltsYDir = (int)filer.ReadItem("_numBoltsYDir");
    _intermediateDistX = (double)filer.ReadItem("_intermediateDistX");
    _intermediateDistY = (double)filer.ReadItem("_intermediateDistY");
    _offsetX = (double)filer.ReadItem("_offsetX");
    _offsetY = (double)filer.ReadItem("_offsetY");
    _staggerDist = (double)filer.ReadItem("_staggerDist");

    _edge1 = (double)filer.ReadItem("_edge1");
    _edge2 = (double)filer.ReadItem("_edge2");
    _edge3 = (double)filer.ReadItem("_edge3");
    _edge4 = (double)filer.ReadItem("_edge4");

    _layout = (int)filer.ReadItem("_layout");
    _connector = (int)filer.ReadItem("_connector");
    _reference = (int)filer.ReadItem("_reference");
    _stagger = (int)filer.ReadItem("_stagger");
}

CreateObjects() method

This is the method that does all the calculations, object creation, modification, etc. The Query() method will have already been called so that the input elements will be available in the IJoint object. From the input elements and the user-modifiable parameters, the connection objects are created and added to the IJoint with the setCreatedObjects() method.

Code Region: Implement CreateObjects

public void CreateObjects()
{
    // get my start points
    IJoint joint = DatabaseManager.Open(JointId) as IJoint;
    IEnumerable<FilerObject> input = joint.InputObjects;
    
    // prepare the output
    List<CreatedObjectInformation> arrCOI = new List<CreatedObjectInformation>();

    // TODO: Create objects and put in arrCOI list

    // created objects need to be set to the joint
    joint.setCreatedObjects(arrCOI, true);
}

Was this information helpful?