muck Posted December 30, 2017 Posted December 30, 2017 The following procedure works in the command class to change dimstyle variables. I can used the command DimStyleChange to change dim style variables. [CommandMethod("DimStyleChange")] // public static void CreateModifyDimStyle1(string DimStyleName, out string message) public void StandardStyleChange() { String DimStyleName; DimStyleName = "Standard"; System.Windows.Forms.MessageBox.Show("Test"); // Initialise the message value that gets returned by an exception (or not!) message = string.Empty; try { using (Transaction tr = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction()) { Database db = Application.DocumentManager.MdiActiveDocument.Database; DimStyleTable dst = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForWrite, true); //System.Windows.Forms.MessageBox.Show("Test"); // Initialise a DimStyleTableRecord DimStyleTableRecord dstr = null; // If the required dimension style exists if (dst.Has(DimStyleName)) { // get the dimension style table record open for writing dstr = (DimStyleTableRecord)tr.GetObject(dst[DimStyleName], OpenMode.ForWrite); } else // Initialise as a new dimension style table record dstr = new DimStyleTableRecord(); // Set all the available dimension style properties // Most/all of these match the variables in AutoCAD. dstr.Name = DimStyleName; // If the dimension style doesn't exist if (!dst.Has(DimStyleName)) { // Add it to the dimension style table and collect its Id Object dsId = dst.Add(dstr); // Add the new dimension style table record to the document tr.AddNewlyCreatedDBObject(dstr, true); } dstr.Dimasz = 0.1875;//Arrow head size dstr.Dimscale = 5;//Dim Scale dstr.Dimtxt = 0.085;//Dim Text size // Commit the changes. tr.Commit(); } } catch (Autodesk.AutoCAD.Runtime.Exception e) { message = e.Message.ToString(); } } But when I create a form button and try to start the above method the proceedure does not make changes. So what should I look at to trouble shoot? Here is my button code. private void button7_Click(object sender, EventArgs e) { MyCommands ObjMycommands = new MyCommands(); ObjMycommands.StandardStyleChange(); } Thank you, Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.