Page 1 of 1

How to add fonts to cadImage library, I have tried, but can not search fonts

Posted: 03 Feb 2023, 10:24
by 15069127176
I added the shx path with the following code, but the number of fonts searched was 0; I don't know what went wrong. I hope you can help me. Thank you very much.

SearchedFonts = Count = 0

Code: Select all


  CADImage cAD = CADImage.CreateImageByExtension(@"d:\123.dwg");
            cAD.LoadFromFile(@"d:\123.dwg");
         
            var shxFonts = cAD.Converter.SHXSettings;
            string shxPath = Path.GetFullPath(@".\shx");
            var shxFonts1 = cAD.Converter.SHXFonts;
            shxFonts1.SearchPath.Clear();
            shxFonts1.SearchPath.Add(shxPath);
            cAD.SearchSHXPaths = true;
            cAD.SHXSearchPaths = shxPath;
            cAD.UseSHXFonts = true;
            var shxFonts2 = cAD.Converter.SHXFonts;
            foreach (var item in cAD.Converter.Entities)
            {
                if (item is CADShape shape)
                {
                    // shape.ShapeName = "742";
                }
            }
            CADtoDWG.SaveAsDWG(cAD, @"d:\999.dwg");

            CADExport expObject = new CADtoDXF(cAD);
            expObject.SaveToFile("d:\\666.dxf");

Re: How to add fonts to cadImage library, I have tried, but can not search fonts

Posted: 07 Feb 2023, 14:08
by support
15069127176 wrote:
03 Feb 2023, 10:24
I added the shx path with the following code, but the number of fonts searched was 0; I don't know what went wrong. I hope you can help me. Thank you very much.

SearchedFonts = Count = 0

Code: Select all


  CADImage cAD = CADImage.CreateImageByExtension(@"d:\123.dwg");
            cAD.LoadFromFile(@"d:\123.dwg");
         
            var shxFonts = cAD.Converter.SHXSettings;
            string shxPath = Path.GetFullPath(@".\shx");
            var shxFonts1 = cAD.Converter.SHXFonts;
            shxFonts1.SearchPath.Clear();
            shxFonts1.SearchPath.Add(shxPath);
            cAD.SearchSHXPaths = true;
            cAD.SHXSearchPaths = shxPath;
            cAD.UseSHXFonts = true;
            var shxFonts2 = cAD.Converter.SHXFonts;
            foreach (var item in cAD.Converter.Entities)
            {
                if (item is CADShape shape)
                {
                    // shape.ShapeName = "742";
                }
            }
            CADtoDWG.SaveAsDWG(cAD, @"d:\999.dwg");

            CADExport expObject = new CADtoDXF(cAD);
            expObject.SaveToFile("d:\\666.dxf");
Hello,
Please, have a look at the code example below:

Code: Select all

private void menuItem14_Click(object sender, EventArgs e)
  {
   CADImage cAD = CADImage.CreateImageByExtension(@"d:\123.dwg");
   cAD.LoadFromFile(@"d:\123.dwg");
   
   string SHXPath = @"D:\SHX\Fonts\SHX";//for example
   CADConst.SHXSearchPaths += SHXPath;//adds a path, where shx fonts are located            
   string savePath = @"d:\test123SHAPE.dxf";
   CADtoDXF vExp = new CADtoDXF(cAD);
   vExp.SaveToFile(savePath);   
  }
Please, note that at the moment saving CADShapes entities in DWG files is not supported.

Catherine.

Re: How to add fonts to cadImage library, I have tried, but can not search fonts

Posted: 09 Mar 2023, 12:42
by MichealStanton
Thanks for helping me out as well, if I face any more problem, I will message here.