.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

WClone "Standard" Textstyle bug?

3 REPLIES 3
Reply
Message 1 of 4
Techno Destructo
449 Views, 3 Replies

WClone "Standard" Textstyle bug?

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);
}
}
}
}
3 REPLIES 3
Message 2 of 4
cadMeUp
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.
Message 3 of 4

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.
Message 4 of 4
Anonymous
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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost