CAD Viewer problem

Discuss and ask questions about CAD .NET library.

Moderators: support, SDS, admin

Post Reply
vitoluigi
Posts: 2
Joined: 30 Oct 2018, 16:13

CAD Viewer problem

Post by vitoluigi » 30 Oct 2018, 16:57

Hi,

it's the first time I write here. I implemented a CAD Viewer following the demo. All types of images are opened and the zoom is applied. But there are two problems: when I open an image dwg or dxf there are no colors and I can not interpret the letters that are replaced with strange symbols. What am I forgetting? Attach images to better understand the problem.
Immagine.png
Immagine.png (26.34 KiB) Viewed 9023 times
Thanks for your help

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

Re: CAD Viewer problem

Post by support » 30 Oct 2018, 17:21

Hello,

Could you please also attach the source code of your CAD Viewer for better understanding of the problem?

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

vitoluigi
Posts: 2
Joined: 30 Oct 2018, 16:13

Re: CAD Viewer problem

Post by vitoluigi » 30 Oct 2018, 17:54

Sure, for now place these functions that are the main ones

Code: Select all

public void LoadFile(string fileName)
        {
            _fileName = fileName;
       
            if (fileName != null)
            {
                if (cadImage != null)
                {
                    cadImage.Dispose();
                    cadImage = null;
                    //this.lForm.LayerList.Clear();
                }

                ImageScale = 1.0f;

                this.cadImage = CADImage.CreateImageByExtension(fileName);
                CADImport.CADConst.DefaultSHXParameters.UseSHXFonts = this.useSHXFonts;
                if (this.useSHXFonts)
                    DoSHXFonts();
                else
                    DoTTFFonts();
                this.cadImage.ChangeGraphicsMode(graphicsMode, renderMode);      
                this.cadImage.GraphicsOutMode = graphicsMode;
                this.cadImage.ChangeDrawMode(graphicsMode, cadPictBox);
                this.cadImage.ChangeGraphicsMode(graphicsMode, renderMode);
                if (this.cadImage is CADRasterImage)
                    (this.cadImage as CADRasterImage).Control = this.cadPictBox;
            }
            if (this.cadImage != null)
            {
                CADImage.CodePage = System.Text.Encoding.Default.CodePage;//note - charset was set here
                CADImage.LastLoadedFilePath = Path.GetDirectoryName(fileName);
                CreateNewLoadThread(fileName);
            }
        }

Code: Select all

private void LoadCADImage(object fileNameObj)
        {
            lock (cadImage)
            {
                string fileName = (string)fileNameObj;
                
                if (CADConst.IsWebPath(fileName))
                    this.cadImage.LoadFromWeb(fileName);
                else
                    cadImage.LoadFromFile(fileName);
            }
 
            SetCADImageOptions();
        }

Code: Select all

public void SetCADImageOptions()
        {
            cadImage.IsShowLineWeight = this.showLineWeight;
            cadImage.IsWithoutMargins = true;
            cadImage.UseDoubleBuffering = this.useDoubleBuffering;
            cadImage.TTFSmoothing = TTFSmoothing.None;
            this.useSelectEntity = false;

            if (cadPictBox.BackColor == Color.White)
                White_Click();
            else
                Black_Click();
                
            if (this.DrawMode == false)
                this.DoBlackColor();

            ObjEntity.cadImage = cadImage;
            ObjEntity.propGrid = this.propGrid;
            DoResize(true, true);
            this.cadPictBox.Invalidate();
        }
The rest of the functions are almost the same. If you need something more specific, ask.

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

Re: CAD Viewer problem

Post by support » 30 Oct 2018, 22:30

Hello,

I have noticed that your code includes DoBlackColor() call, in the ViewerDemo project the given method renders the CAD image in black and white. To determine what rendering mode is currently used, you should check a CADImage.DrawMode property value which may be the following:

Code: Select all

    public enum CADDrawMode
    {
        //     All colors are shown.
        Normal = 0,
        //     CAD image is shown in black and white.
        Black = 1,
        //     CAD image is shown in grayscale.
        Gray = 2,
    } 
The problem with wrong characters may be connected with the usage of incorrect font. Please check what SHX and TTF fonts are required by the drawing file (for example, in AutoCAD). If you don't have AutoCAD, send the drawing file to the Technical Support e-mail, we will check it ourselves.

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

Post Reply