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

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
15069127176
Posts: 1
Joined: 03 Feb 2023, 09:05

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

Post by 15069127176 » 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");

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

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

Post by support » 07 Feb 2023, 14:08

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

MichealStanton
Posts: 3
Joined: 09 Mar 2023, 12:41

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

Post by MichealStanton » 09 Mar 2023, 12:42

Thanks for helping me out as well, if I face any more problem, I will message here.
Last edited by MichealStanton on 30 Mar 2023, 16:18, edited 1 time in total.

Post Reply