@mudassir.fayyaz
Can you please elaborate your requirements for drawing rectangles as API does not support it currently.
For my goals, I would like to have standart rectangle’s functionality as: opportunity to hatch it with given samples (SOLID, ANGLE, ANSI31 etc). Opportunity to change it’s color, transparency, opacity. Possibility to change border’s width, color, style. That’s what I would like to see in your future rectangle support But I guess there should be more available features in AutoCAD to implement in your library.
For this, can you please share the details with us for required properties so that we may help you further.
My main question is how to get entity coordinates on the layer? For example, I have method deleteAllEntities which takes RectangleF as parameter. Inside this method I want to delete all entities that are inside this rectangle. For this purpose I am iterating through cadImage.BlockEntities["*Model_Space"].Entities. Each entity is ICadBaseEntity and it does not have any coordinates, offsets, alignments etc. To detect where this entity is positioned I have to cast it. That looks to me like not optimized solution. Example is shown below.
private void DeleteAllEntities(CadImage cadImage, RectangleF rectangle)
{
foreach (ICadBaseEntity baseEntity in cadImage.BlockEntities["*Model_Space"].Entities)
{
if (baseEntity.GetType() == typeof(CadText))
{
CadText entityText = (CadText)baseEntity;
List<Point> entityPoints = new List<Point>
{
new Point((float) entityText.FirstAlignment.X, (float) entityText.FirstAlignment.Y),
new Point((float) entityText.FirstAlignment.X , (float) entityText.FirstAlignment.Y + (float)entityText.TextHeight),
new Point((float) entityText.FirstAlignment.X + (float)entityText.TextWidth, (float) entityText.FirstAlignment.Y),
new Point((float) entityText.FirstAlignment.X + (float)entityText.TextWidth, (float) entityText.FirstAlignment.Y + (float)entityText.TextHeight)
};
if (InIntersected(rectangle, entityPoints))
{
// todo logic
}
}
else if (baseEntity.GetType() == typeof(CadMText))
{
CadMText entityText = (CadMText)baseEntity;
List<Point> entityPoints = new List<Point>
{
new Point((float) entityText.InsertionPoint.X, (float) entityText.InsertionPoint.Y),
new Point((float) entityText.InsertionPoint.X , (float) entityText.InsertionPoint.Y + (float)entityText.InitialTextHeight),
new Point((float) entityText.InsertionPoint.X + (float)entityText.HorizontalWidth, (float) entityText.InsertionPoint.Y),
new Point((float) entityText.InsertionPoint.X + (float)entityText.HorizontalWidth, (float) entityText.InsertionPoint.Y + (float)entityText.InitialTextHeight)
};
if (InIntersected(rectangle, entityPoints))
{
// todo logic
}
}
else if (baseEntity.GetType() == typeof(CadCircle))
{
CadCircle entityCircle = (CadCircle)baseEntity;
Tuple<Cad3DPoint, double> circleCoords =
new Tuple<Cad3DPoint, double>(entityCircle.CenterPoint, entityCircle.Radius);
if (InIntersected(rectangle, circleCoords))
{
// todo logic
}
}
// etc
}
}
Now I actively research Aspose.CAD library so I came up with 3rd question. How do I set text style for CadMText component? By text style I mean Italic, Bold, Strikeout, Underline. And is it possible, for example, to strikeout just part of the text?
Thanks for help