Author Topic: FontDescriptor - eInvalidInput with ISO03908b.shx  (Read 2786 times)

0 Members and 1 Guest are viewing this topic.


  • Guest
FontDescriptor - eInvalidInput with ISO03908b.shx
« on: September 23, 2009, 09:34:57 PM »
I'm looking for some insight.  I've got some code, (attached below), which has been eating away at my nerves for the last 2 hours.  It is designed to change the font size of a specified text style based on the current drawing scale.  However, it is having problems accessing the font iso3098b.
The code works in selecting simple fonts like romans, or times new romans...

Any ideas?

Code: [Select]
public static void GT_TextStyle(string sName, string sFont,double dFontSize, double dWidthFactor)
            //Reference the current active drawing and database
            Document acDWG = Application.DocumentManager.MdiActiveDocument;
            Database acDB = acDWG.Database;

            //Start a new transaction with the transaction manager
            using (Transaction acTrans = acDB.TransactionManager.StartTransaction())
                //Create an instance of the TextStyleTable for comparisons
                TextStyleTable acTST = acTrans.GetObject(acDB.TextStyleTableId, OpenMode.ForWrite, false) as TextStyleTable;

                //If the TextStyleTable does NOT have the specified name
                if (!acTST.Has(sName))
                    //Create a new TextStyleTableRecord
                    TextStyleTableRecord acTSTR = new TextStyleTableRecord();
                    //Set the name for the new TextStyle
                    acTSTR.Name = sName;
                    //Set the TextStyle Font, Not Bold, Not Italic, Characters, Pitch&Family
                    acTSTR.Font = new FontDescriptor(sFont, false, false, 0, 0);
                    //Let the user set the WidthFactor
                    acTSTR.XScale = dWidthFactor;
                    acTSTR.Annotative = AnnotativeStates.False;
                    //Get the Font Size Based on the current Dimension Scale
                    acTSTR.TextSize = Convert.ToInt32(Application.GetSystemVariable("DIMSCALE")) * dFontSize;
                    acTrans.AddNewlyCreatedDBObject(acTSTR, true);
                //If the TextStyle does exist
                    //Identify the ID of the Style Name
                    ObjectId TSid = acTST[sName];
                    //Make a reference of it for ediditng
                    TextStyleTableRecord acTSTR = acTrans.GetObject(TSid, OpenMode.ForWrite) as TextStyleTableRecord;
                    //We assume that the style was set up correctly, so we are going to just update the Text Size
                    acTSTR.TextSize = Convert.ToInt32(Application.GetSystemVariable("DIMSCALE")) * dFontSize;
                    //Add the altered style record
                    //Commit the transaction
                    acTrans.AddNewlyCreatedDBObject(acTSTR, true);
                //Commit the Transaction
                //Dispose of the Transaction


  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: FontDescriptor - eInvalidInput with ISO03908b.shx
« Reply #1 on: September 23, 2009, 10:24:07 PM »
Can't make the time to have a look .... and not really sure WHAT the problem is

does this help ...
« Last Edit: September 23, 2009, 10:33:26 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.


  • Guest
Re: FontDescriptor - eInvalidInput with ISO03908b.shx
« Reply #2 on: September 23, 2009, 10:41:11 PM »

On further review of your snippets Kerry, I can just set the style.FileName to the name of the font I desire, AutoCAD identifying it of course.
« Last Edit: September 23, 2009, 10:49:29 PM by Xander »