(API) Generating Persistent Labels for Structural Axis

(API) Generating Persistent Labels for Structural Axis

liam_mchale
Contributor Contributor
871 Views
2 Replies
Message 1 of 3

(API) Generating Persistent Labels for Structural Axis

liam_mchale
Contributor
Contributor

I am trying to define the Structural Axis for a 2D Frame. I want to assign labels at various X & Z axis positions which will be visible within the Structural Axis dialogue box.

 

With my current code, the structural axis is active upon opening the ROBOT file, and the defined labels are visible on import. However the labels are not 'loaded' into the Structural Axis dialogue. Additionally there is odd behaviour where the last label element of the Z-axis is being defined on a different basis (1-99) than the rest of the Z axis labels (A-Z).

 

Specific labels are not loaded into the structural axis dialogue box.Specific labels are not loaded into the structural axis dialogue box.

 

IRobotStructuralAxisGridMngr robotStructuralAxisGridMngr = _robotApplication.Project.AxisMngr;
            
IRobotStructuralAxisGridCartesian grid = (IRobotStructuralAxisGridCartesian)robotStructuralAxisGridMngr.Create(IRobotStructuralAxisGridType.I_SAGT_CARTESIAN, "Structure Axis");

grid.X.SetLabelFormat(IRobotStructuralAxisLabelType.I_SALT_123);
grid.Z.SetLabelFormat(IRobotStructuralAxisLabelType.I_SALT_ABC);

foreach(var label in structuralModel.labels.Z){ 
  grid.Z.AddSequence(label.SequenceDistance, 0);
  grid.Save();
}

foreach(var label in structuralModel.labels.X){
  grid.X.AddSequence(label.SequenceDistance, 0);
  grid.Save();
}

var gridIndex = robotStructuralAxisGridMngr.FindByName(grid.Name);
robotStructuralAxisGridMngr.Activate(gridIndex);

 

Appreciate any advice on how to achieve persistent import of Axis Labels & any other code improvements. 

 

Thank you and regards,

Liam McHale

0 Likes
Accepted solutions (1)
872 Views
2 Replies
Replies (2)
Message 2 of 3

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @liam_mchale 

Below is a generic code for the forum that you can modify to suit your specific case.

using RobotOM;
using static RobotOM.IRobotStructuralAxisLabelType;
using static RobotOM.IRobotStructuralAxisGridType;
using static RobotOM.IRobotGeoCoordinateAxis;
using System;

namespace GridAxis
{
    internal class Program
    {
        static void Main()
        {
            RobotApplication RobApp = new RobotApplication();
            bool isVisible = RobApp.Visible == -1,
                  IsActive = RobApp.Project.IsActive == -1;
            if (!(isVisible && IsActive)) { RobApp = null; return; }


            RobotStructuralAxisGridMngr AxisMngr = RobApp.Project.AxisMngr;
            RobotStructuralAxisGridCartesian AxisGrid;
            AxisGrid = (RobotStructuralAxisGridCartesian)AxisMngr.Create(I_SAGT_CARTESIAN, "my cartesian Axis");
            AxisGrid.IncludeStoreysInZ = true;
            AxisGrid.SetRelativeToPoint(true, 1, 1, 1);
            AxisGrid.RotationAxis = I_GCA_OZ;
            AxisGrid.RotationAngle = Math.PI / 6;

            RobotStructuralAxisSequenceList XAxis = AxisGrid.X,
                                            YAxis = AxisGrid.Y,
                                            ZAxis = AxisGrid.Z;

            XAxis.SetLabelFormat(I_SALT_123);
            foreach(double x in new double[] { 7.08, 6.35, 5.56, 3.57, 2.23 }) 
                XAxis.AddSequence(x, 1);

            YAxis.SetLabelFormat(I_SALT_ABC);
            YAxis.AddSequence(12.7, 2);
            YAxis.SetAxisLabel(1, "Existing Line A");

            ZAxis.SetLabelFormat(I_SALT_DEFINE, "Level_%+v");
            ZAxis.AddSequence(5, 1);
            ZAxis.AddSequence(1.5, 1);

            AxisGrid.Save();

            RobApp = null;
        }   
    }
}

Stephanekapetanovic_2-1705512295827.png

Kind Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
Message 3 of 3

liam_mchale
Contributor
Contributor

thank you @Stephane.kapetanovic , worked like a charm.