Multiply Text

Multiply Text

k005
Advisor Advisor
1,015 Views
5 Replies
Message 1 of 6

Multiply Text

k005
Advisor
Advisor

Hi all,

 

I want to create a two-line text ( DBtext) when I click on a point. (I'm stuck in the code I indicated in red...)

 

the space between the two; As far as font height...

 

How can I do that ?

 

Thank you in advance for the help.

 

 

acText.SetDatabaseDefaults();
acText.Position = pointRes.Value;
acText.Height = YaziYuks;
acText.TextString = TxtVeri + "\n\n" + Txtveri2;
acBlkTblRec.AppendEntity(acText);
tr.AddNewlyCreatedDBObject(acText, true);
tr.Commit();
ed.WriteMessage("\n......OK!\n");

0 Likes
1,016 Views
5 Replies
Replies (5)
Message 2 of 6

_gile
Consultant
Consultant

Hi,

 

DBText -> single line text

MText  -> multiline text



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 6

k005
Advisor
Advisor

I use this as a method. That's the one line one.


Now we need a two-line one.

more precisely, I need the multiple one... but how should I design it?

so txtveri is like txtveri2 txtverixx...

Thanks.

 

 public void YaziOlustur2(string TxtVeri,string Txtveri2)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            double YaziYuks = db.Textsize * 1.5;
            DBText acText = new DBText();
            using (DocumentLock docLock = doc.LockDocument())
            using (Transaction tr = doc.TransactionManager.StartTransaction())
            {

                BlockTable acBlkTbl;
                acBlkTbl = tr.GetObject(db.BlockTableId,
                                             OpenMode.ForRead) as BlockTable;

                BlockTableRecord acBlkTblRec;
                acBlkTblRec = tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;

                var pointRes = ed.GetPoint("\nNereye Yazılsın ? >");
                if (pointRes.Status != PromptStatus.OK)
                {
                    ed.WriteMessage("\n\nNokta bulunamadı\n");
                    return;
                }

                acText.SetDatabaseDefaults();
                acText.Position = pointRes.Value;
                acText.Height = YaziYuks;
                acText.TextString = TxtVeri + "\n\n" + Txtveri2;
                acBlkTblRec.AppendEntity(acText);
                tr.AddNewlyCreatedDBObject(acText, true);
                tr.Commit();
                ed.WriteMessage("\n......OK!\n");
            }

        } // birleşik yazar.
0 Likes
Message 4 of 6

fieldguy
Advisor
Advisor

Did you try this manually in autocad?  Start the "text" command, use text "line 1", press enter, use text "line 2", etc.

When you check the result, there are separate "text" entities for each line.  You cannot create a single text entity that has multiple lines. 

Message 5 of 6

k005
Advisor
Advisor

Yes. I know. There are no two lines in DBtext.

 

my goal is to give separate variables (which are two in this code. txtveri , txtveri2 ) with a space between them as much

 

as the default font height, and just click on a point and write it.


Thanks.

0 Likes
Message 6 of 6

fieldguy
Advisor
Advisor

Right.  The user clicks for the insertion of the first text and your program calculates the insertion point of the second, third and so on.  The distance is calculated by adding text height and a space factor (1/2 the text height or something similar).