Page 1 of 1

Add text in a drawing DWG in 3D

Posted: 29 Jul 2014, 22:08
by dmvcad
I am testing the DEMO of CADImport .NET, How can I add a label with text in any element/part/entity of a drawing DWG in 3D?

Re: Add text in a drawing DWG in 3D

Posted: 30 Jul 2014, 14:37
by support
Hello,

The code example below shows how to add a text programmatically:

Code: Select all

 
        private void AddText(CADImage cadImage, DPoint basePoint, string textValue)
        {
            if (cadImage == null)
            {
                return;
            }
            else
            {
                if (cadImage.CurrentLayout == null)
                    return;
            }
            CADText text = new CADText();  
            text.Point = basePoint;
            text.Height = 10;
            text.Text = textValue;

            text.Loaded(cadImage.Converter);
            cadImage.Converter.OnCreate(text);
            cadImage.CurrentLayout.AddEntity(text);
            cadImage.GetExtents();
        }
Each new entity should be loaded into CADConverter and added to some layout (usually, to the current layout). After that, you need to redraw the image using CADImage.Draw() method.


Mikhail