Free Support Forum - aspose.com

CAD rectangle and position question

Hello,

Is there a way to draw rectangle using Aspose.CAD? I didn’t find such element in your entities but this is the basic element and for sure must be supported. Of course, I could draw it using polyline but polyline, for example, can’t be filled, can’t have a border and so on.

And my second question is how do I get a position of ICadBaseEntity? Some of them have Alignment value, some of them have coordinates. Is there any unified property where I can get position of an object.

Regards

1 Like

I am also looking for a way for drawing elements by coordinates.
is there anybody do it before??

@AlexBilakovskyi

Can you please elaborate your requirements for drawing rectangles as API does not support it currently.

For this, can you please share the details with us for required properties so that we may help you further.

@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 :slight_smile: 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

@AlexBilakovskyi

I have created a ticket with ID CADNET-1351 in our issue tracking system to further analyze the requirements shared by you. We will get back to you with feedback as soon as the investigation will be completed internally on our end.