Page 1 of 1
CAD Viewer problem
Posted: 30 Oct 2018, 16:57
by vitoluigi
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 (26.34 KiB) Viewed 13545 times
Thanks for your help
Re: CAD Viewer problem
Posted: 30 Oct 2018, 17:21
by support
Hello,
Could you please also attach the source code of your CAD Viewer for better understanding of the problem?
Mikhail
Re: CAD Viewer problem
Posted: 30 Oct 2018, 17:54
by vitoluigi
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.
Re: CAD Viewer problem
Posted: 30 Oct 2018, 22:30
by support
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