<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Leader with MText annotation in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580422#M82391</link>
    <description>Is anyone (else?) getting this method to work, and have it associate an annotation with a leader?</description>
    <pubDate>Wed, 06 Aug 2008 18:45:35 GMT</pubDate>
    <dc:creator>McSwiller</dc:creator>
    <dc:date>2008-08-06T18:45:35Z</dc:date>
    <item>
      <title>Leader with MText annotation</title>
      <link>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580418#M82387</link>
      <description>Hello!&lt;BR /&gt;
&lt;BR /&gt;
I tried to draw a leader, with a MText which has an annotation with it (Like the AutoCAD QLeader).&lt;BR /&gt;
But when I run it in AutoCAD i get the following Error:&lt;BR /&gt;
&lt;BR /&gt;
Befehl: ATDrawQLeader&lt;BR /&gt;
Autodesk.AutoCAD.Runtime.Exception: eNotInDatabase&lt;BR /&gt;
   bei Autodesk.AutoCAD.Runtime.Interop.ThrowExceptionForErrorStatus(Int32 &lt;BR /&gt;
errorStatus)&lt;BR /&gt;
   bei Autodesk.AutoCAD.DatabaseServices.Leader.set_Annotation(ObjectId value)&lt;BR /&gt;
   bei AcadTools.Draw_Elements.DrawQLeader() in C:\AcadTools\AcadTools\Draw Elements.cs:Zeile 117.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Can anybody tell me, what the problem is?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Here is my Code:&lt;BR /&gt;
&lt;BR /&gt;
[CommandMethod("ATDrawQLeader")]&lt;BR /&gt;
public void DrawQLeader()&lt;BR /&gt;
{&lt;BR /&gt;
    Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;
    Database db = HostApplicationServices.WorkingDatabase;&lt;BR /&gt;
    Transaction trans = db.TransactionManager.StartTransaction();&lt;BR /&gt;
&lt;BR /&gt;
    try&lt;BR /&gt;
    {&lt;BR /&gt;
        BlockTable bt = (BlockTable)trans.GetObject(HostApplicationServices.WorkingDatabase.BlockTableId, OpenMode.ForRead);&lt;BR /&gt;
        BlockTableRecord btr = (BlockTableRecord)trans.GetObject(HostApplicationServices.WorkingDatabase.CurrentSpaceId, OpenMode.ForWrite);&lt;BR /&gt;
&lt;BR /&gt;
	//Create a MText and add it to the BlockTableRecord&lt;BR /&gt;
        MText mtext = new MText();&lt;BR /&gt;
        mtext.Contents = "Text";&lt;BR /&gt;
        mtext.Location = new Point3d(100, 100, 0);&lt;BR /&gt;
        ObjectId mtextId = btr.AppendEntity(mtext);&lt;BR /&gt;
        trans.AddNewlyCreatedDBObject(mtext, true);&lt;BR /&gt;
&lt;BR /&gt;
	//Create a Leader        &lt;BR /&gt;
        Leader leader = new Leader();&lt;BR /&gt;
        leader.AppendVertex(new Point3d(10,10,0));&lt;BR /&gt;
        leader.AppendVertex(mtext.Location);&lt;BR /&gt;
&lt;BR /&gt;
	//Make a annotation between the Leader and the MText &amp;lt;- it crashes here!&lt;BR /&gt;
        leader.Annotation = mtextId;&lt;BR /&gt;
        &lt;BR /&gt;
	//Add the Leader to the BlockTableRecord&lt;BR /&gt;
        btr.AppendEntity(leader);&lt;BR /&gt;
        trans.AddNewlyCreatedDBObject(leader, true);&lt;BR /&gt;
&lt;BR /&gt;
        trans.Commit();&lt;BR /&gt;
    }&lt;BR /&gt;
    catch (Autodesk.AutoCAD.Runtime.Exception e)&lt;BR /&gt;
    {&lt;BR /&gt;
        ed.WriteMessage(e.ToString());&lt;BR /&gt;
    }&lt;BR /&gt;
    finally&lt;BR /&gt;
    {&lt;BR /&gt;
        trans.Dispose();&lt;BR /&gt;
    }&lt;BR /&gt;
}</description>
      <pubDate>Tue, 14 Mar 2006 16:48:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580418#M82387</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-03-14T16:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Leader with MText annotation</title>
      <link>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580419#M82388</link>
      <description>mabe2k,&lt;BR /&gt;
&lt;BR /&gt;
The error 'eNotInDatabase' seems to mean that you must insert the leader into the block table first.&lt;BR /&gt;
try switching these statements like so:&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
btr.AppendEntity(leader);&lt;BR /&gt;
leader.Annotation = mtextId;&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
let us know if this works&lt;BR /&gt;
C</description>
      <pubDate>Tue, 14 Mar 2006 21:43:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580419#M82388</guid>
      <dc:creator>cgay</dc:creator>
      <dc:date>2006-03-14T21:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Leader with MText annotation</title>
      <link>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580420#M82389</link>
      <description>Thank you!&lt;BR /&gt;
It works great.</description>
      <pubDate>Wed, 15 Mar 2006 07:16:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580420#M82389</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-03-15T07:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Leader with MText annotation</title>
      <link>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580421#M82390</link>
      <description>I'm trying this same methodology, and all I get back when I try to associate the annotation is a eNotApplicable error. (at the line leader.Annotation =  mtext.ObjectId)&lt;BR /&gt;
What am I doing wrong?</description>
      <pubDate>Tue, 05 Aug 2008 21:04:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580421#M82390</guid>
      <dc:creator>McSwiller</dc:creator>
      <dc:date>2008-08-05T21:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Leader with MText annotation</title>
      <link>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580422#M82391</link>
      <description>Is anyone (else?) getting this method to work, and have it associate an annotation with a leader?</description>
      <pubDate>Wed, 06 Aug 2008 18:45:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580422#M82391</guid>
      <dc:creator>McSwiller</dc:creator>
      <dc:date>2008-08-06T18:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Leader with MText annotation</title>
      <link>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580423#M82392</link>
      <description>It *does* work for me too, as written above in C#, but I'm working in VB.Net. -Equivalent code for each line.&lt;BR /&gt;
I still get this error:&lt;BR /&gt;
Autodesk.AutoCAD.Runtime.Exception: eNotApplicable&lt;BR /&gt;
   at Autodesk.AutoCAD.Runtime.Interop.ThrowExceptionForErrorStatus(Int32 errorStatus)&lt;BR /&gt;
   at Autodesk.AutoCAD.Runtime.Interop.Check(Int32 returnValue)&lt;BR /&gt;
   at Autodesk.AutoCAD.DatabaseServices.Leader.set_Annotation(ObjectId value)&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions?</description>
      <pubDate>Wed, 06 Aug 2008 21:27:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580423#M82392</guid>
      <dc:creator>McSwiller</dc:creator>
      <dc:date>2008-08-06T21:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Leader with MText annotation</title>
      <link>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580424#M82393</link>
      <description>Solved - the Z value for vertices needs to be Zero (0).</description>
      <pubDate>Fri, 08 Aug 2008 20:44:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580424#M82393</guid>
      <dc:creator>McSwiller</dc:creator>
      <dc:date>2008-08-08T20:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Leader with MText annotation</title>
      <link>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580425#M82394</link>
      <description>Awesome! &lt;BR /&gt;
&lt;BR /&gt;
Thanks for the advice. This totally fixed a problem I was having! &lt;BR /&gt;
&lt;BR /&gt;
Glad I searched the forum...</description>
      <pubDate>Wed, 27 Aug 2008 20:45:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/leader-with-mtext-annotation/m-p/1580425#M82394</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-27T20:45:26Z</dc:date>
    </item>
  </channel>
</rss>

