There are a many VBA procedures related to drawings in the help file. In this project you will find 14 of the examples related to drawing annotations converted to C#.
This section in the help has has 29 VBA demos.
You can find details about how the C# projects can be used in this post. This project has the following functions:
Download InventorHelpExamples_Drawing_Annotations_1
CenterAllDimensions
EditBalloons
CreateBalloon
GetComponentReferencedByBalloon
CreateBaselineDimensionSet
AddBendNote
CreateChainDimensionSet
CreateCustomTable
CreateBendTable
CreateConfigurationTable
CreateDrawingExcelTable
EditDrawingDimensions
DeleteUnattachedDimensions
DimensionAlign
Here is DimensionAlign:
// Aligning drawing dimensions API Sample
//Description
//This sample demonstrates aligning the selected
//drawing dimensions along a horizontal or vertical
//axis. The first dimension selected defines the
//origin of the axis. A drawing document must be
//open and at least two dimensions selected.
public void DimensionAlign()
{
DrawingDocument oDrawDoc =
(DrawingDocument)ThisApplication.ActiveDocument;
// Determine if there are any dimensions
//in the select set.
SelectSet oSelectSet = default(SelectSet);
oSelectSet = oDrawDoc.SelectSet;
var colDimensions = new List<DrawingDimension>();
// long i = 0;
for (int i = 1; i <= oSelectSet.Count; i++)
{
if (oSelectSet[i] is DrawingDimension)
{
// Add any dimensions to the collection.
//We need to save them
// in something besides the selection
//set because once we start
// manipulating them, the select set
//will be cleared.
colDimensions.Add(oSelectSet[i]);
}
}
if (colDimensions.Count != 2)
{
MessageBox.Show
("Select at least 2 dimensions for this operation.");
return;
}
// Ask the user if he/she wants vertical
//or horizontal alignment.
bool bHorizontal = false;
DialogResult diagRes = MessageBox.Show
("Horizontal alignment? No = vertical alignment)",
"Align Dimensions", MessageBoxButtons.YesNo);
if (diagRes == DialogResult.Yes)
{
bHorizontal = true;
}
else
{
bHorizontal = false;
}
double dPosition = 0;
for (int i = 0;
i <= colDimensions.Count - 1;
i++)
{
DrawingDimension oDimension =
default(DrawingDimension);
oDimension = colDimensions[i];
if (i == 0)
{
// Get the position of the
//first dimension text. This is
// the position the other
//dimensions will be aligned to.
if (bHorizontal)
{
dPosition = oDimension.Text.Origin.Y;
}
else
{
dPosition = oDimension.Text.Origin.X;
}
}
else
{
// Change the position of the dimension.
Point2d oPosition = default(Point2d);
oPosition = oDimension.Text.Origin;
if (bHorizontal)
{
// oPosition.Y = dPosition;
oPosition.Y = dPosition;
}
else
{
// oPosition.X = dPosition;
oPosition.X = dPosition;
}
oDimension.Text.Origin = oPosition;
}
}
}
-Wayne