Set Text in a CADText

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
user
Posts: 3
Joined: 18 Mar 2014, 16:06

Set Text in a CADText

Post by user » 18 Mar 2014, 18:04

Hello,

I have a problem with CADText in a dwg file.

I load the file and then I try to change the text by code, by setting CADText.Text property, but text doesn't change!

Can someone help me?

Thanks!

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

Re: Set Text in a CADText

Post by support » 19 Mar 2014, 11:49

Hello,

The code below assigns a new value to CADText:

Code: Select all


CADImage cadImage;
...

private void ChangeText(string textValue, string newValue)
{
    foreach (CADEntity entity in cadImage.Converter.Entities)
    {
        if (entity.EntType == EntityType.Text)
        {
            CADText cadText = entity as CADText;
            if (cadText.Text == textValue)
            {
                cadText.Text = newValue;
                cadImage.Converter.Loads(cadText);
                cadImage.GetExtents();
            }
        }
    }
}
Mikhail.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

user
Posts: 3
Joined: 18 Mar 2014, 16:06

Re: Set Text in a CADText

Post by user » 19 Mar 2014, 13:44

Thank you Mikhail!

user
Posts: 3
Joined: 18 Mar 2014, 16:06

Re: Set Text in a CADText

Post by user » 19 Mar 2014, 18:02

Hello Mikhail,

It's possible to insert a multiline text in a CADText?

Thank you in advance.

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

Re: Set Text in a CADText

Post by support » 24 Mar 2014, 18:34

Hello.
CAD Import .NET provides CADMText class as multiline texts representation. Any multiline text on a drawing will be imported as CADMText object. If you need to replace single line text with multiline text then delete CADText object and create new MText instead of it.

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

Post Reply