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

0 Members and 1 Guest are viewing this topic.

Andrey Bushman

  • Swamp Rat
  • Posts: 860
Re: Cell styles in TableStyle...
« Reply #30 on: July 26, 2010, 03:04:03 AM »
May be it not work for AutoCAD 2009?

In Windows XP x86 SP3 I see reference, and can add it in my Project:



But...



The problem remained... (((

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cell styles in TableStyle...
« Reply #31 on: July 26, 2010, 03:27:37 AM »

What happens if you use these references ??

the ObjectARX 2009 Reference:
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Andrey Bushman

  • Swamp Rat
  • Posts: 860
Re: Cell styles in TableStyle...
« Reply #32 on: July 26, 2010, 03:38:05 AM »

What happens if you use these references ??

the ObjectARX 2009 Reference:


At first I did too. You can see result on my Reply #24 on: July 25, 2010, 03:41:47 pm for Windows 7 x64 (I showed the screen).

For Windows XP x86 other screen:


« Last Edit: July 26, 2010, 03:45:20 AM by Hwd »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cell styles in TableStyle...
« Reply #33 on: July 26, 2010, 03:50:31 AM »


Perhaps you could remove ALL the AutoCad based references and re-reference them :)

Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cell styles in TableStyle...
« Reply #34 on: July 26, 2010, 03:55:01 AM »
Quote
At first I did too. You can see result on my Reply #24 on: July 25, 2010, 03:41:47 pm for Windows 7 x64 (I showed the screen).

For Windows XP x86 other screen:

Have the rules changed again ??

Which version and Operating System are you actually trying to build on ???
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Andrey Bushman

  • Swamp Rat
  • Posts: 860
Re: Cell styles in TableStyle...
« Reply #35 on: July 26, 2010, 04:07:20 AM »


Perhaps you could remove ALL the AutoCad based references and re-reference them :)

If I delete AutoCAD reference, then I get result which I show on my Reply #17 on: July 25, 2010, 12:57:30 pm.
Quote
Have the rules changed again ??

Which version and Operating System are you actually trying to build on

I have Windows 7 x64 Ultimate and AutoCAD 2009 x64 SP3 Enu on my home.
I have Windows XP x86 SP3 Professional and AutoCAD 2009 x86 SP3 Enu on my office (work).

Some my users use Windows 7 x64, and some - Windows XP x86 SP3 Professional. Most my users (99%) use AutoCAD 2009.

Quote
Perhaps you could remove ALL the AutoCad based references and re-reference them
I tried to do it.


Kerry

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


Perhaps you could remove ALL the AutoCad based references and re-reference them :)

If I delete AutoCAD reference, then I get result which I show on my Reply #17 on: July 25, 2010, 12:57:30 pm.

re-read what I said.
Remove the ALL AutoCAD based references.
Reference them again.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cell styles in TableStyle...
« Reply #37 on: July 26, 2010, 04:12:34 AM »
Quote
Have the rules changed again ??

Which version and Operating System are you actually trying to build on

I have Windows 7 x64 Ultimate and AutoCAD 2009 x64 SP3 Enu on my home.
I have Windows XP x86 SP3 Professional and AutoCAD 2009 x86 SP3 Enu on my office (work).

Some my users use Windows 7 x64, and some - Windows XP x86 SP3 Professional. Most my users (99%) use AutoCAD 2009.


great. How about resolving ONE issue at a time.
Choose one build and get it correct.
Then resolve the other build.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Kerry

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

Quote
Perhaps you could remove ALL the AutoCad based references and re-reference them
I tried to do it.


Perhaps you should try again
... and tell us which build you are working on.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Andrey Bushman

  • Swamp Rat
  • Posts: 860
Re: Cell styles in TableStyle...
« Reply #39 on: July 26, 2010, 04:28:17 AM »
Quote
great. How about resolving ONE issue at a time.
Choose one build and get it correct.
Then resolve the other build.
and
Quote
Perhaps you should try again
... and tell us which build you are working on.
Most important variant - Windows XP x86 SP3 and AutoCAD 2009 x86.

I write video (YouTobe):
http://www.youtube.com/watch?v=TMNdpoNopxg

fixo write me, what on him AutoCAD 2009 all it good work. I was tangled... (((
I have asked him to send me a full project code - then I  compare all references.
« Last Edit: July 26, 2010, 04:51:59 AM by Hwd »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Cell styles in TableStyle...
« Reply #40 on: July 26, 2010, 04:53:21 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;
 
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Andrey Bushman

  • Swamp Rat
  • Posts: 860
The problem is solved
« Reply #41 on: July 26, 2010, 05:05:54 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;
 

Yes!!!!! ))))))
I use code from Reply #16 on: July 25, 2010, 12:15:56 pm within IAcadTableStyle. Now I change on IAcadTableStyle2 and all ok!!!!

All Thanks for help!
« Last Edit: July 26, 2010, 05:20:33 AM by Hwd »

fixo

  • Guest
Re: Cell styles in TableStyle...
« Reply #42 on: July 26, 2010, 05:42:13 AM »
With this one can add a cellstyle, delete a cellstyle, set the textstyle for a cellstyle.
It requires you to add some textstyles and a tablestyle
1) Apparantly it is impossible (whatever you do don't actually try it)
2) It probably is no use to the OP , as it is in no way what he wanted.
3) Who wants to use interop anyway.

Code: [Select]
       [CommandMethod("tts")]
        public static void TableStyleTest()
        {
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            string tableStyleName = "YourTableStyle";

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                TableStyle tableStyle;
                DBDictionary dic = tr.GetObject(db.TableStyleDictionaryId, OpenMode.ForRead) as DBDictionary;
                foreach (DictionaryEntry eDict in dic)
                {
                    tableStyle = tr.GetObject
                        ((ObjectId)eDict.Value, OpenMode.ForRead) as TableStyle;
                    if (tableStyle.Name == tableStyleName)
                    {
                        tableStyle.UpgradeOpen();

                        ArrayList ca = tableStyle.CellStyles;
                        interop.AcadApplication Ap = (interop.AcadApplication)acadApp.AcadApplication;
                        object ob = Ap.ActiveDocument.ObjectIdToObject( tableStyle.ObjectId.OldId);
                        interop.Common.IAcadTableStyle ts = ob as interop.Common.IAcadTableStyle;

                        TextStyleTable textstyletable=tr.GetObject
                            (db.TextStyleTableId,OpenMode.ForRead) as TextStyleTable;
                        object ob2 = Ap.ActiveDocument.ObjectIdToObject(textstyletable.ObjectId.OldId);
                        interop.Common.IAcadTextStyles tss = ob2 as interop.Common.IAcadTextStyles;
                      
                      
                        if(ca.Contains("U1")) ts.DeleteCellStyle("U1");
                        ts.CreateCellStyle("U1");
                        ts.SetCellClass("U1", 1);
                        if (ca.Contains("U2")) ts.DeleteCellStyle("U2");
                        ts.CreateCellStyle("U2");
                        ts.SetCellClass("U2", 2);
                        if (ca.Contains("U3")) ts.DeleteCellStyle("U3");
                        ts.CreateCellStyle("U3");
                        ts.SetCellClass("U3", 3);

                        ed.WriteMessage(tss.Item("User1").ObjectID.ToString());
                        if(textstyletable.Has("User1"))
                            ts.SetTextStyleId("U1", tss.Item("User1").ObjectID);

                        if (textstyletable.Has("User2"))
                            ts.SetTextStyleId("U2", tss.Item("User2").ObjectID);

                        if (textstyletable.Has("User3"))
                            ts.SetTextStyleId("U3", tss.Item("User3").ObjectID);
                    }

                }
                tr.Commit();
            }
            
        } // end TableStyleTest

Thanks, Bryco, ya da man!
I've adopted your code to my A2009
It's working like a charm
Regards,

Oleg

~'J'~

pkohut

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

What software was used to annotate Kerry's and Hwd's pictures.  Can never be enough cool tools.
« Last Edit: July 26, 2010, 06:08:52 AM by pkohut »

Andrey Bushman

  • Swamp Rat
  • Posts: 860
Re: Cell styles in TableStyle...
« Reply #44 on: July 26, 2010, 06:08:42 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