<?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: eInvalidInput while reading block attributes in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7613158#M28700</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;in which line does the error accure?&lt;/P&gt;&lt;P&gt;Regards Jürgen&lt;/P&gt;</description>
    <pubDate>Mon, 11 Dec 2017 11:24:22 GMT</pubDate>
    <dc:creator>Juergen_Becker</dc:creator>
    <dc:date>2017-12-11T11:24:22Z</dc:date>
    <item>
      <title>eInvalidInput while reading block attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7612227#M28698</link>
      <description>&lt;P&gt;Trying to read block attributes from drawing gives me eInvalidInput most of the time&lt;/P&gt;&lt;P&gt;I don't really understand this error&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was working fine 2 days ago and now is just failing most of the time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone could&amp;nbsp;help me out. The class Atribute map is just a simple Key/Value pair class that store the block attributes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is the code is failing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/// &amp;lt;see cref="&lt;A href="https://forums.autodesk.com/t5/net/find-block-inside-a-polyline/td-p/7586489&amp;quot;/" target="_blank"&gt;https://forums.autodesk.com/t5/net/find-block-inside-a-polyline/td-p/7586489"/&lt;/A&gt;&amp;gt;&lt;BR /&gt;public static IEnumerable&amp;lt;AttributeMap&amp;gt; GetBlockAttributesInsidePolyline(ObjectId id)&lt;BR /&gt;{&lt;BR /&gt;Document doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;doc.LockDocument();&lt;BR /&gt;Database db = doc.Database;&lt;BR /&gt;Editor ed = doc.Editor;&lt;BR /&gt;ObjectId[] ids = null;&lt;BR /&gt;using (Transaction tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;Polyline pline = (Polyline)tr.GetObject(id, OpenMode.ForRead);&lt;BR /&gt;PromptSelectionResult selection = ed.SelectByPolyline(pline, PolygonSelectionMode.Window, new TypedValue(0, "INSERT"));&lt;BR /&gt;if (selection.Status == PromptStatus.OK)&lt;BR /&gt;{&lt;BR /&gt;ed.SetImpliedSelection(selection.Value);&lt;BR /&gt;ids = selection.Value.GetObjectIds(); -----------&amp;gt;here is whare it hapens most of the time---------------------------------------&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;catch (Autodesk.AutoCAD.Runtime.Exception e)&lt;BR /&gt;{&lt;BR /&gt;Controller.TagController.CurrentDrawing.Logger.Error(string.Format("Polyline Handle {0} had an error: {1} ",&lt;BR /&gt;id.Handle.ToString(), e.Message));&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return GetBlockAttributes(ids);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/// &amp;lt;see cref="&lt;A href="http://through-the-interface.typepad.com/through_the_interface/2006/09/getting_autocad.html&amp;quot;/" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2006/09/getting_autocad.html"/&lt;/A&gt;&amp;gt;&lt;BR /&gt;/// &amp;lt;param name="ids"&amp;gt;ObjectIds&amp;lt;/param&amp;gt;&lt;BR /&gt;public static IEnumerable&amp;lt;AttributeMap&amp;gt; GetBlockAttributes(ObjectId[] ids)&lt;BR /&gt;{&lt;BR /&gt;//There should be just one object Id in the ids&lt;BR /&gt;Document doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;doc.LockDocument();&lt;BR /&gt;Database db = doc.Database;&lt;BR /&gt;List&amp;lt;AttributeMap&amp;gt; attributes = new List&amp;lt;AttributeMap&amp;gt;();&lt;BR /&gt;if (ids != null)&lt;BR /&gt;{&lt;BR /&gt;using (Transaction tr = db.TransactionManager.StartOpenCloseTransaction())&lt;BR /&gt;{&lt;BR /&gt;foreach (ObjectId id in ids)&lt;BR /&gt;{&lt;BR /&gt;BlockReference blkRef = (BlockReference)tr.GetObject(id, OpenMode.ForRead);&lt;BR /&gt;BlockTableRecord btr = (BlockTableRecord)tr.GetObject(blkRef.BlockTableRecord, OpenMode.ForRead);&lt;BR /&gt;Controller.TagController.CurrentDrawing.Logger.Info("Block: " + btr.Name);&lt;BR /&gt;btr.Dispose();&lt;/P&gt;&lt;P&gt;AttributeCollection attCol = blkRef.AttributeCollection;&lt;BR /&gt;foreach (ObjectId attId in attCol)&lt;BR /&gt;{&lt;BR /&gt;AttributeReference attRef = (AttributeReference)tr.GetObject(attId, OpenMode.ForRead);&lt;BR /&gt;string str = string.Format(" Attribute Tag: {0}{1} Attribute String: {2}", attRef.Tag, System.Environment.NewLine, attRef.TextString);&lt;BR /&gt;Controller.TagController.CurrentDrawing.Logger.Info(str);&lt;BR /&gt;attributes.Add(new AttributeMap { Field = attRef.Tag, Value = attRef.TextString });&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;tr.Commit();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return attributes;&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 00:31:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7612227#M28698</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-12-11T00:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: eInvalidInput while reading block attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7612663#M28699</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;aramosvizcarra a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is the code is failing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/// &amp;lt;see cref="&lt;A href="https://forums.autodesk.com/t5/net/find-block-inside-a-polyline/td-p/7586489&amp;quot;/" target="_blank"&gt;https://forums.autodesk.com/t5/net/find-block-inside-a-polyline/td-p/7586489"/&lt;/A&gt;&amp;gt;&lt;BR /&gt;public static IEnumerable&amp;lt;AttributeMap&amp;gt; GetBlockAttributesInsidePolyline(ObjectId id)&lt;BR /&gt;{&lt;BR /&gt;Document doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;doc.LockDocument();&lt;BR /&gt;Database db = doc.Database;&lt;BR /&gt;Editor ed = doc.Editor;&lt;BR /&gt;ObjectId[] ids = null;&lt;BR /&gt;using (Transaction tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;Polyline pline = (Polyline)tr.GetObject(id, OpenMode.ForRead);&lt;BR /&gt;PromptSelectionResult selection = ed.SelectByPolyline(pline, PolygonSelectionMode.Window, new TypedValue(0, "INSERT"));&lt;BR /&gt;if (selection.Status == PromptStatus.OK)&lt;BR /&gt;{&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ed.SetImpliedSelection(selection.Value);&lt;/FONT&gt;&lt;BR /&gt;ids = selection.Value.GetObjectIds(); -----------&amp;gt;here is whare it hapens most of the time---------------------------------------&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;catch (Autodesk.AutoCAD.Runtime.Exception e)&lt;BR /&gt;{&lt;BR /&gt;Controller.TagController.CurrentDrawing.Logger.Error(string.Format("Polyline Handle {0} had an error: {1} ",&lt;BR /&gt;id.Handle.ToString(), e.Message));&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;return GetBlockAttributes(ids);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Try removing: ed.SetImpliedSelection(selection.Value);&lt;/P&gt;
&lt;P&gt;This expression was only a way to display the result of the selection in &lt;A href="https://forums.autodesk.com/t5/net/find-block-inside-a-polyline/td-p/7586489" target="_blank"&gt;the example&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 07:03:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7612663#M28699</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-12-11T07:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: eInvalidInput while reading block attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7613158#M28700</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;in which line does the error accure?&lt;/P&gt;&lt;P&gt;Regards Jürgen&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 11:24:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7613158#M28700</guid>
      <dc:creator>Juergen_Becker</dc:creator>
      <dc:date>2017-12-11T11:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: eInvalidInput while reading block attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7613620#M28701</link>
      <description>&lt;P&gt;Thank once again,that seems to solved it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just for curiosity why that line may be causing the issue?.&lt;/P&gt;&lt;P&gt;I couldn't find in the reference document that method.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 14:24:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7613620#M28701</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-12-11T14:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: eInvalidInput while reading block attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7613945#M28702</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;aramosvizcarra a écrit&amp;nbsp;:&lt;BR /&gt;
&lt;P&gt;Thank once again,that seems to solved it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just for curiosity why that line may be causing the issue?.&lt;/P&gt;
&lt;P&gt;I couldn't find in the reference document that method.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;After calling Editor.SetImpliedSelection, the selection set entities are highlighted/gripped, in other words, the selection set is "opened" for adding or removing entities to it. That's why you cannot acces to the SelectionSet.GetObjectIds() method.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2017 15:47:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/einvalidinput-while-reading-block-attributes/m-p/7613945#M28702</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-12-11T15:47:11Z</dc:date>
    </item>
  </channel>
</rss>

