And add these to the [message 2] Class1 class
and have a play
[CommandMethod("RectandPolarAssocArr")]
public void RectandPolarAssocArr()
{
Document doc = CadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
var rectArrayEntitiesIds = new ObjectIdCollection();
var polarArrayEntitiesIds = new ObjectIdCollection();
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId,
OpenMode.ForRead);
BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace],
OpenMode.ForWrite);
var circle = new Circle(Point3d.Origin, Vector3d.ZAxis, 5);
modelSpace.AppendEntity(circle);
tr.AddNewlyCreatedDBObject(circle, true);
var line = new Line(Point3d.Origin, new Point3d(5, 0, 0));
modelSpace.AppendEntity(line);
tr.AddNewlyCreatedDBObject(line, true);
rectArrayEntitiesIds.Add(circle.ObjectId);
polarArrayEntitiesIds.Add(line.ObjectId);
var rectParams = new AssocArrayRectangularParameters()
{
ColumnCount = 10,
ColumnSpacing = 10,
RowCount = 10,
RowSpacing = 10,
RowElevation = 0,
LevelCount = 10,
LevelSpacing = 10,
XAxisDirection = Vector3d.XAxis,
YAxisDirection = Vector3d.YAxis,
BasePoint = new VertexRef(new Point3d(50, 50, 0))
};
AssocArray.CreateArray(rectArrayEntitiesIds, rectParams.BasePoint, rectParams);
var polarParams = new AssocArrayPolarParameters()
{
FillAngle = 360,
AngleBetweenItems = 10,
ItemCount = 36,
RowCount = 10,
RowElevation = 10,
RowSpacing = 10,
Radius = 30,
Direction = AssocArrayPolarParameters.ArcDirection.CounterClockwise,
StartAngle = 0,
RotateItems = true
};
AssocArray.CreateArray(polarArrayEntitiesIds, new VertexRef(new Point3d(100, 100, 0)), polarParams);
tr.Commit();
}
}
[CommandMethod("ModifyRectandPolarAssocArr")]
public void ModifyRectandPolarAssocArr()
{
Document doc = CadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
var peo = new PromptEntityOptions(Environment.NewLine + "Select a Array: ");
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK)
{
return;
}
if (!AssocArray.IsAssociativeArray(per.ObjectId))
{
return;
}
AssocArray array = AssocArray.GetAssociativeArray(per.ObjectId);
if (array.GetParameters() is AssocArrayPolarParameters)
{
AssocArrayPolarParameters arrayPolarParam =
(AssocArrayPolarParameters)array.GetParameters();
arrayPolarParam.ItemCount = arrayPolarParam.ItemCount / 2;
arrayPolarParam.RowCount = arrayPolarParam.RowCount / 2;
arrayPolarParam.RowSpacing = arrayPolarParam.RowSpacing / 2;
arrayPolarParam.Commit();
}
else if (array.GetParameters() is AssocArrayRectangularParameters)
{
AssocArrayRectangularParameters arrayRecParam =
(AssocArrayRectangularParameters)array.GetParameters();
arrayRecParam.ColumnCount = arrayRecParam.ColumnCount / 2;
arrayRecParam.RowCount = arrayRecParam.RowCount / 2;
arrayRecParam.RowSpacing = arrayRecParam.RowSpacing / 2;
arrayRecParam.Commit();
}
else
{
return;
}
tr.Commit();
}
}
// Called Kerry or kdub in my other life.
Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub
NZST UTC+12 : class keyThumper<T> : Lazy<T>; another Swamper