TheSwamp

Code Red => .NET => Topic started by: itcad on December 09, 2008, 11:55:52 PM

Title: How to create Text in autocad2005?
Post by: itcad on December 09, 2008, 11:55:52 PM
In autocad2005,it hasn't DBText,but it has Text.
I use the code:
Text tx = new Text();

but it's wrong.
Who can tell me how to create Text (not MText) in autocad2005?
Title: Re: How to create Text in autocad2005?
Post by: Kerry on December 10, 2008, 03:34:18 AM
public class Text : Entity
Name: Autodesk.AutoCAD.DatabaseServices.Text
Assembly: acdbmgd, Version=16.1.63.0

 
Title: Re: How to create Text in autocad2005?
Post by: itcad on December 10, 2008, 07:56:06 PM
public class Text : Entity
Name: Autodesk.AutoCAD.DatabaseServices.Text
Assembly: acdbmgd, Version=16.1.63.0

 


what you mean? cann't it create Text in autocad2005?
Title: Re: How to create Text in autocad2005?
Post by: kdub_nz on December 10, 2008, 09:37:44 PM
public class Text : Entity
Name: Autodesk.AutoCAD.DatabaseServices.Text
Assembly: acdbmgd, Version=16.1.63.0

 


what you mean? cann't it create Text in autocad2005?

The reference posted is from the ACAD2005 acdbmgd.dll .. and has a reference to a Text Class in the Autodesk.AutoCAD.DatabaseServices namespace

I don't have AC2005 installed.
What code have you tried ?
Can you post the Method you are using ( or have tried)

Title: Re: How to create Text in autocad2005?
Post by: Kerry on December 12, 2008, 11:43:28 PM
Perhaps you could try something like this ..
Code: [Select]
[CommandMethod("TestText")]
static public void TestDbText()
// CodeHimBelongaKbub@TheSwamp ©  Dec 2008
{
    Database db = HostApplicationServices.WorkingDatabase;
    string txtStr = "This is a DbText string.";
    string txtStyle = "kbubsComicTextStyle";

    using (Transaction tr = db.TransactionManager.StartTransaction())
    {
        BlockTableRecord CurrentSpaceBtr = tr.GetObject(db.CurrentSpaceId,
                                            OpenMode.ForWrite) as BlockTableRecord ;
        DBText textObj = new DBText();
        textObj.TextString = txtStr;
        textObj.Height = 500;
        textObj.Position = new Point3d(0,0,0) ;
       
        textObj.HorizontalMode = TextHorizontalMode.TextMid;
        textObj.AlignmentPoint = textObj.Position;

        TextStyleTable txtTbl = tr.GetObject(db.TextStyleTableId,
                            OpenMode.ForRead) as TextStyleTable ;
        if (txtTbl.Has(txtStyle))
        {
            TextStyleTableRecord txtTbr = tr.GetObject(txtTbl[txtStyle],
                                        OpenMode.ForRead) as TextStyleTableRecord;
            textObj.TextStyle = txtTbr.ObjectId;
        }

        CurrentSpaceBtr.AppendEntity(textObj);
        tr.AddNewlyCreatedDBObject(textObj, true);

        tr.Commit();
    }
}
Title: Re: How to create Text in autocad2005?
Post by: Kerry on December 12, 2008, 11:50:32 PM
.... Though, this routine was built in VS2008 for AC2008 using DbText
so you may need to modify it for AC2005 using Text ..
ie
Text textObj = new Text();

I cant test in AC2005, sorry
Title: Re: How to create Text in autocad2005?
Post by: itcad on December 13, 2008, 04:53:52 AM
.... Though, this routine was built in VS2008 for AC2008 using DbText
so you may need to modify it for AC2005 using Text ..
ie
Text textObj = new Text();

I cant test in AC2005, sorry


DBText textObj = new DBText();

I cant test in AC2005.
Title: Re: How to create Text in autocad2005?
Post by: Kerry on December 13, 2008, 06:32:44 AM
Please post the code you have.
Title: Re: How to create Text in autocad2005?
Post by: Kerry on December 13, 2008, 09:02:58 AM

Sorry, I can't help you with AutoCAD2005  I'd be playing guessing games.