.NET

Reply
Active Contributor
Techno Destructo
Posts: 47
Registered: ‎04-05-2006
Message 1 of 4 (175 Views)

WClone "Standard" Textstyle bug?

175 Views, 3 Replies
11-16-2007 06:35 PM
I have noticed that if an existing drawing has a textstyle named Standard and it has been modified (font aerial instead of default txt)
and then you clone it out to a NEW database and save to new file
The new file contains AutoCADs default "Standard" textstyle not the Modified "Standard" textstyle you cloned out.

To see what I mean, try this.
Open a drawing change the "Standard" text style to have any font but "txt".

Now clone it out to a NEW db and save.
Open the drawing and the "Standard" text style will have font "txt"

How can I clone out the standard with the correct overides!
(I have noticed that this happens with table styles as well)

Here is the code I used:
public void CloneTextStyle()
{

using (Database dbCur = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database)
{
using (Transaction trCur = dbCur.TransactionManager.StartTransaction())
{

TextStyleTable tst = (TextStyleTable)trCur.GetObject(dbCur.TextStyleTableId, OpenMode.ForRead);
TextStyleTableRecord tstr = (TextStyleTableRecord)trCur.GetObject(tst["Standard"], OpenMode.ForRead);

ObjectIdCollection idColl = new ObjectIdCollection();
idColl.Add(tstr.ObjectId);

using (Database dbNew = new Database(true, true))
{
using (Transaction trNew = dbNew.TransactionManager.StartTransaction())
{
dbNew.WblockCloneObjects(idColl, dbNew.TextStyleTableId, new IdMapping(), DuplicateRecordCloning.Replace, false);
trNew.Commit();
}

dbNew.SaveAs(@"c:\test.dwg", DwgVersion.Current);
}
}
}
}
Valued Mentor
cadMeUp
Posts: 331
Registered: ‎05-11-2006
Message 2 of 4 (175 Views)

Re: WClone "Standard" Textstyle bug?

11-17-2007 01:54 AM in reply to: Techno Destructo
I think it is because the "Standard" text style cannot be deleted, that would also make it un-replaceable. So there's really no point in trying to clone it to another dwg.

It would be the same thing if you were to, for example, change the color of layer "0" to red and then clone layer "0" to a new database. When you open that file that you created you would see that layer "0" has the color white. Obviously layer "0" can't be deleted.

You are better off setting the font of the "Standard" style other than trying to replace it:

>> tstr.FileName = "simplex.shx";

I am surprised to see though, that an exception is not thrown when calling 'WblockCloneObjects' using 'DuplicateRecordCloning.Replace' as the parameter value, but I guess it still is a valid call.
Active Contributor
Techno Destructo
Posts: 47
Registered: ‎04-05-2006
Message 3 of 4 (175 Views)

Re: WClone "Standard" Textstyle bug?

11-17-2007 08:11 PM in reply to: Techno Destructo
Thanks Larry,

Thats what I feared.
It really is a bother to have to set the standard:
Text Style
Table Style
and as you pointed out any other defaults manually.

There are a lot of properties for each.
*Tony Tanzillo
Message 4 of 4 (175 Views)

Re: WClone "Standard" Textstyle bug?

11-18-2007 12:25 AM in reply to: Techno Destructo
Just a little clarification:

It's not the 'Standard' text style, it is the first
entry in the text style table. You can rename
that style to something else but it will still be
treated the same by AutoCAD.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5780306@discussion.autodesk.com...
I think it is because the "Standard" text style cannot be deleted, that would also make it un-replaceable. So there's really no point in trying to clone it to another dwg.

It would be the same thing if you were to, for example, change the color of layer "0" to red and then clone layer "0" to a new database. When you open that file that you created you would see that layer "0" has the color white. Obviously layer "0" can't be deleted.

You are better off setting the font of the "Standard" style other than trying to replace it:

>> tstr.FileName = "simplex.shx";

I am surprised to see though, that an exception is not thrown when calling 'WblockCloneObjects' using 'DuplicateRecordCloning.Replace' as the parameter value, but I guess it still is a valid call.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.