Author Topic: Cell styles in TableStyle...  (Read 21935 times)

0 Members and 1 Guest are viewing this topic.

pkohut

  • Guest
Re: Cell styles in TableStyle...
« Reply #45 on: July 26, 2010, 06:10:24 AM »
Problem solved, now I'll ask my OT question.

What software was used to annotate Kerry's and Hwd's pictures.  Can never be enough cool tools.
this

Cool, thanks.  That is on my sort list already of software to checkout. Been reading lots of good reviews about it but hadn't really seen it in action.

Glenn R

  • Guest
Re: Cell styles in TableStyle...
« Reply #46 on: July 26, 2010, 06:28:35 AM »
The video was a bit unclear for me.

I just looked at  the contents of  Autodesk.AutoCAD.Interop.Common for 2009

There is a public interface  IAcadTableStyle : IAcadObject

and a public interface IAcadTableStyle2 : IAcadTableStyle

ONLY the IAcadTableStyle2 has
void DeleteCellStyle(string bstrCellStyle);
void CreateCellStyle(string bstrCellStyle);

I can't test this, but perhaps try

// interop.Common.IAcadTableStyle ts = ob as interop.Common.IAcadTableStyle;
interop.Common.IAcadTableStyle2 ts = ob as interop.Common.IAcadTableStyle2;
 


They're Versioned COM interfaces Kerry - we've been seeing that for some years now e.g. IAcadBlock1 2 and 3, possibly more. A COM interface can't really be changed once it's 'published', so devleopers tend to 'version' them...at least that's what I remember from my C++ COM days...

Glenn R

  • Guest
Re: Cell styles in TableStyle...
« Reply #47 on: July 26, 2010, 06:29:43 AM »
...they version them to add the 'new' features of the underlying objects they want to expose...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cell styles in TableStyle...
« Reply #48 on: July 26, 2010, 06:56:46 AM »
...they version them to add the 'new' features of the underlying objects they want to expose...

Yes, that's what I discovered ... needed to look at the library in the Browser or Reflector to sort it out ... should have done that earlier I s'pose :)
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.

Glenn R

  • Guest
Re: Cell styles in TableStyle...
« Reply #49 on: July 26, 2010, 06:58:57 AM »
You could probably apply the technique TT showed a couple of years ago here, about using PInvoke on an arx object. It was to do with the default indexer's on Symboltables returning erased objects...you might remember it...I'll have a dig on here...

Glenn R

  • Guest
Re: Cell styles in TableStyle...
« Reply #50 on: July 26, 2010, 07:03:51 AM »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cell styles in TableStyle...
« Reply #51 on: July 26, 2010, 07:18:03 AM »
Andrey,
Something you may want to check before you wrap this one up.

Is the library released with AC2009 (and any service pack) the same at the SDK ObjectARX2009.

ie: are
void DeleteCellStyle(string bstrCellStyle);
void CreateCellStyle(string bstrCellStyle);

in the interface IAcadTableStyle2 for the released version ??
« Last Edit: July 26, 2010, 07:35:30 AM 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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cell styles in TableStyle...
« Reply #52 on: July 26, 2010, 07:20:11 AM »
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.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Cell styles in TableStyle...
« Reply #53 on: July 26, 2010, 07:54:35 AM »

I do not trust PayPal - they have deceived many people (I read about it). Has the forum a electronic purse on WebMoney?
« Last Edit: July 26, 2010, 08:01:32 AM by Hwd »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cell styles in TableStyle...
« Reply #54 on: July 26, 2010, 08:02:47 AM »

I don't know of anyone at theSwamp who has been deceived.


Perhaps an Administrator would like to move this discussion to a more suitable location.
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.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Cell styles in TableStyle...
« Reply #55 on: July 26, 2010, 08:19:54 AM »
I don't know of anyone at theSwamp who has been deceived.
I am afraid to enter of my confidential data (data of my card) on page www.paypal.com
But I can do remittance on WebMoney electronic purse.

Ok. I learn as do it safe today.
« Last Edit: July 26, 2010, 08:24:10 AM by Hwd »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cell styles in TableStyle...
« Reply #56 on: July 26, 2010, 08:29:04 AM »

Andrey,
I'll forward this on to Mark who is the site owner ... he should be able to answer your question.

I wasn't suggesting that you had to make a donation, and that's not the reason I became involved in your problem.
I posted that comment because I know that a lot of people will be looking at that thread over the next few months and donations are always appreciated because they help keep this place operating.

Thanks and Regards,
Kerry
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.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Cell styles in TableStyle...
« Reply #57 on: July 26, 2010, 09:03:29 AM »
Thanks Oleg.

Glenn R

  • Guest
Re: Cell styles in TableStyle...
« Reply #58 on: July 26, 2010, 09:38:58 AM »
A quicky for 2010:

Code: [Select]

using System;
using System.Runtime.InteropServices;

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;


using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;

[assembly: CommandClass(typeof(CellStyles.MyCommands))]

namespace CellStyles
{
    public class MyCommands
    {
        [CommandMethod("q1", CommandFlags.Modal)]
        public void TestMethod()
        {
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            using (Transaction tr = doc.TransactionManager.StartTransaction())
            {
                DBDictionary tsd = (DBDictionary) tr.GetObject(db.TableStyleDictionaryId, OpenMode.ForRead);
                foreach (DBDictionaryEntry item in tsd)
                {
                    TableStyle ts = (TableStyle)tr.GetObject(item.Value, OpenMode.ForRead);
                    ed.WriteMessage(string.Format("{0}Table style name: '{1}'", Environment.NewLine, ts.Name));
                    ed.WriteMessage(string.Format("{0}(TableStyle.CellStyles.IsReadOnly ='{1}')",
                        Environment.NewLine, ts.CellStyles.IsReadOnly));

                    //Print all cell style names of table style
                    PrintCellStylesInfo(ts);
                    string stName = "MyStyle";// name for my new cell style

                    ed.WriteMessage(string.Format("{0}Before modify: Cell Styles Count: {1}",
                        Environment.NewLine, ts.CellStyles.Count));

                    ts.UpgradeOpen();

                    AcDbTable.createCellStyle(ts.UnmanagedObject, stName);

                    ed.WriteMessage(string.Format("{0}After modify: Cell Styles Count: {1}{0}",
                                    Environment.NewLine, ts.CellStyles.Count));

                    ts.SetCellClass(CellClass.Label, stName);

                    ed.WriteMessage(string.Format("{0}{1}{0}", "\nAfter modify:", new string('*', 30)));
                    //Print all cell style names of table style
                    PrintCellStylesInfo(ts);
                }

                tr.Commit();
            }         
        }
 
        private void PrintCellStylesInfo(TableStyle ts)
        {
            foreach (var cs in ts.CellStyles)
            {
                Document doc = acadApp.DocumentManager.MdiActiveDocument;
                Editor ed = doc.Editor;
                ed.WriteMessage(string.Format("{0}CellStyle Type: '{1}'; CellStyle.ToString: {2}",
                                Environment.NewLine, cs.GetType(), cs.ToString()));
            }           
        }
    }

    public static class AcDbTable
    {
        // Acad::ErrorStatus createCellStyle(const ACHAR* pszCellStyle);

        [System.Security.SuppressUnmanagedCodeSecurity]
        [DllImport("acdb18.dll", CallingConvention = CallingConvention.ThisCall, CharSet = CharSet.Unicode,
           EntryPoint = "?createCellStyle@AcDbTableStyle@@QEAA?AW4ErrorStatus@Acad@@PEB_W@Z")]
        public static extern ErrorStatus createCellStyle(IntPtr tableStyle, string name);
    }

}

Glenn R

  • Guest
Re: Cell styles in TableStyle...
« Reply #59 on: July 26, 2010, 09:39:30 AM »
2010 64bit btw...