How can I change/save values of entities within an image

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
MatthewCzajka
Posts: 2
Joined: 18 Aug 2021, 17:56

How can I change/save values of entities within an image

Post by MatthewCzajka » 18 Aug 2021, 18:01

I have the current code and I want to change the value of text fields from what they are to something different and save the file as a new temp file.

Code: Select all

		CADImage cadImage = CADImage.CreateImageByExtension(@"file path to file");
                cadImage.LoadFromFile(@"file path to file");
                CADEntityCollection entities = cadImage.Converter.Entities;

                foreach (CADEntity entity in entities)
                {
                    if (entity.EntType.ToString() == "Text")
                    {
                        // change current text value of entity to a new text value
                        
                    }
                }
                //save to new temp .dwg file
                

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: How can I change/save values of entities within an image

Post by support » 19 Aug 2021, 12:28

Hello,

To change the value of TEXT entity, please use the following code:

Code: Select all

if (entity.EntType == EntityType.Text)
{
    CADText text = entity as CADText;
    text.Text = "NewValue";
    cadImage.Converter.Loads(text);
}
As for saving to a DWG file, you will find instructions in the given topic: viewtopic.php?f=15&t=10198

Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply