basic dimension no longer basic after processing drawing

basic dimension no longer basic after processing drawing

Anonymous
Not applicable
277 Views
0 Replies
Message 1 of 1

basic dimension no longer basic after processing drawing

Anonymous
Not applicable

Dear AutoCAD Experts,

I wrote a script that loads a dxf file (created with Solid Edge), saves it as a dwg, then closes the dxf and opens the dwg. It then proceeds to replace an XREF, fill out the title block and correct some formatting issues. It is this latter part that is causing me some headache. When I open the dxf in AutoCAD basic dimensions look like this:

before scriptbefore script

After I run it through my script it looks like this:

after.PNG

Note how the basic dimension are no longer basic dimensions. Here's the code I use to change the format:

var textStyles = (TextStyleTable)trans.GetObject(db.TextStyleTableId, OpenMode.ForRead);
                    foreach (ObjectId oid in btrLayout)
                    {
                        var ent = (Entity)trans.GetObject(oid, OpenMode.ForWrite);

                        string strEntTyp = ent.GetRXClass().DxfName;
                        if (strEntTyp == "INSERT")
                        {
                            BlockReference brGT = (BlockReference)trans.GetObject(oid,OpenMode.ForWrite);
                            string strEntName = brGT.Name.ToUpper();
                            if (strEntName.Contains("GROUP"))
                            {
                                BlockTableRecord btrGT = (BlockTableRecord)trans.GetObject(brGT.BlockTableRecord, OpenMode.ForRead);
                                //BlockTableRecord btrGT = (BlockTableRecord)trans.GetObject(brDim.BlockTableRecord, OpenMode.ForWrite);
                                foreach (ObjectId oidGT in btrGT)
                                {
                                    TextStyleTable TxtStlTbl = trans.GetObject(db.TextStyleTableId,OpenMode.ForRead) as TextStyleTable;

                                    Entity entGT = (Entity)trans.GetObject(oidGT, OpenMode.ForWrite);
                                    string strEntGT = entGT.GetRXClass().DxfName;
                                    if (strEntGT.Equals("TEXT"))
                                    {
                                        string styleName = "ACISOGDT";
                                        if (!TxtStlTbl.Has(styleName))
                                        {
                                            TextStyleTableRecord TxtStlTblRec = new TextStyleTableRecord();
                                            TxtStlTblRec.FileName = "amgdt.shx";
                                            TxtStlTblRec.Name = styleName;
                                            TxtStlTbl.UpgradeOpen();
                                            TxtStlTbl.Add(TxtStlTblRec);
                                            trans.AddNewlyCreatedDBObject(TxtStlTblRec, true);
                                            TxtStlTbl.DowngradeOpen();
                                        }
                                        DBText txtGT = (DBText)trans.GetObject(oidGT, OpenMode.ForWrite);
                                        string strGT = txtGT.getTextWithFieldCodes();
                                        txtGT.TextString = strGT;
                                        switch (strGT)
                                        {
                                            case "l":
                                                txtGT.TextString = "j";
                                                txtGT.TextStyleId = TxtStlTbl["ACISOGDT"];
                                                break;
                                            case "d":
                                                txtGT.TextString = "i";
                                                txtGT.TextStyleId = TxtStlTbl["ACISOGDT"];
                                                break;
                                            case "a":
                                                txtGT.TextString = "r";
                                                txtGT.TextStyleId = TxtStlTbl["ACISOGDT"];
                                                break;
                                            case "i":
                                                txtGT.TextString = "f";
                                                txtGT.TextStyleId = TxtStlTbl["ACISOGDT"];
                                                break;
                                            case "r":
                                                txtGT.TextString = "c";
                                                txtGT.TextStyleId = TxtStlTbl["ACISOGDT"];
                                                break;
                                            case "n":
                                                txtGT.TextString = "b";
                                                txtGT.TextStyleId = TxtStlTbl["ACISOGDT"];
                                                break;
                                            case "O":
                                                txtGT.TextString = "%%C";
                                                break;
                                            default:
                                                break;
                                        }
                                    }
                                }
                            }
                        }
                        if (strEntTyp == "DIMENSION")
                        {
                            Dimension dim = (Dimension)trans.GetObject(oid, OpenMode.ForWrite);
                            string strDim = dim.DimensionText;
                            dim.SuppressTrailingZeros = true;
                            dim.SuppressAngularTrailingZeros = true;
                        }
                    }

At the very bottom is where I actually change the dimension. I need to do this because those basic dimensions actually have three trailing zeros if I didn't. Furthermore, when I try to switch those basic dimensions back manually by clicking on the "Theoretically Exact" button in the Power Dimensioning>Representation tab, the dimensions do not change.

 

0 Likes
278 Views
0 Replies
Replies (0)