<?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: insert a block with attribute doesn't show up in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484917#M70650</link>
    <description>after 30 hours of playing around. i finally found the problem and i can say that i am sure it is the bug with the API.&lt;BR /&gt;
&lt;BR /&gt;
so i am doing this whole thing by accessing the db like this:&lt;BR /&gt;
&lt;BR /&gt;
     Dim db As Database = New Database(False, False)&lt;BR /&gt;
      db.ReadDwgFile(TestPath, IO.FileShare.ReadWrite, True, "")&lt;BR /&gt;
&lt;BR /&gt;
instead of &lt;BR /&gt;
&lt;BR /&gt;
     Dim db As Database = New Database(False, False)&lt;BR /&gt;
        db = Application.DocumentManager.MdiActiveDocument.Database&lt;BR /&gt;
&lt;BR /&gt;
i tried open the drawing first in editor then the block is perfect, for some reason if i open the database by "readingdwgfile" then the block insertion is always lower left. is there a way to call an update block withing the API, like synchronize block in Cad.&lt;BR /&gt;
&lt;BR /&gt;
thank you</description>
    <pubDate>Wed, 13 May 2009 01:26:04 GMT</pubDate>
    <dc:creator>wang890</dc:creator>
    <dc:date>2009-05-13T01:26:04Z</dc:date>
    <item>
      <title>insert a block with attribute doesn't show up</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484912#M70645</link>
      <description>i am trying to insert a block with 4 attribute to paperspace and i got the block inserted ok, but then you can't see it unless you do a quickselect and it's there, but you only see the insertion grip but not the attribute grips. try to insert the created block with autocad command works ok. so which means block created properly.&lt;BR /&gt;
&lt;BR /&gt;
    'insert revision block&lt;BR /&gt;
                            Dim br As New BlockReference(New Point3d(dX_RevisionInsert, y2 - dRev_V_Offset * dBorderScale, 0), Create_Revision_Note_Block(db))&lt;BR /&gt;
                            BTR_Layout.AppendEntity(br)&lt;BR /&gt;
&lt;BR /&gt;
                            'Dim revBtr As BlockTableRecord = trans.GetObject(br.BlockTableRecord, OpenMode.ForRead)&lt;BR /&gt;
                            Dim revBtr As BlockTableRecord = trans.GetObject(bt(Rev_Block_Name), OpenMode.ForRead)&lt;BR /&gt;
&lt;BR /&gt;
                            For Each id As ObjectId In revBtr&lt;BR /&gt;
&lt;BR /&gt;
                                Dim oAttDef As AttributeDefinition&lt;BR /&gt;
                                Dim oAttRef As AttributeReference = New AttributeReference()&lt;BR /&gt;
                                Dim ent As Entity = trans.GetObject(id, OpenMode.ForRead, False)&lt;BR /&gt;
&lt;BR /&gt;
                                If TypeOf ent Is AttributeDefinition Then&lt;BR /&gt;
                                    oAttDef = CType(ent, AttributeDefinition)&lt;BR /&gt;
&lt;BR /&gt;
                                    oAttRef.Height = oAttDef.Height&lt;BR /&gt;
                                    oAttRef.Rotation = oAttDef.Rotation&lt;BR /&gt;
                                    oAttRef.Tag = oAttDef.Tag&lt;BR /&gt;
&lt;BR /&gt;
                                    Select Case oAttDef.Tag&lt;BR /&gt;
&lt;BR /&gt;
                                        Case Rev_No_Tag&lt;BR /&gt;
                                            oAttRef.TextString = CStr(iRevision)&lt;BR /&gt;
                                        Case Rev_Date_Tag&lt;BR /&gt;
                                            oAttRef.TextString = sRevDate&lt;BR /&gt;
                                        Case Rev_Desc_Tag&lt;BR /&gt;
                                            oAttRef.TextString = sRevDesc&lt;BR /&gt;
                                        Case Rev_Sig_Tag&lt;BR /&gt;
                                            oAttRef.TextString = sRevSig&lt;BR /&gt;
                                    End Select&lt;BR /&gt;
                                End If&lt;BR /&gt;
&lt;BR /&gt;
                                br.AttributeCollection.AppendAttribute(oAttRef)&lt;BR /&gt;
                                trans.AddNewlyCreatedDBObject(oAttRef, True)&lt;BR /&gt;
                            Next&lt;BR /&gt;
&lt;BR /&gt;
                            br.SetDatabaseDefaults()&lt;BR /&gt;
                            trans.AddNewlyCreatedDBObject(br, True)</description>
      <pubDate>Fri, 08 May 2009 05:01:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484912#M70645</guid>
      <dc:creator>wang890</dc:creator>
      <dc:date>2009-05-08T05:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: insert a block with attribute doesn't show up</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484913#M70646</link>
      <description>Try look at this post&lt;BR /&gt;
&lt;BR /&gt;
http://discussion.autodesk.com/forums/message.jspa?messageID=6144800#6144800</description>
      <pubDate>Fri, 08 May 2009 07:59:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484913#M70646</guid>
      <dc:creator>BrentBurgess1980</dc:creator>
      <dc:date>2009-05-08T07:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: insert a block with attribute doesn't show up</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484914#M70647</link>
      <description>attributes showed up now, but the text positions is not the same as the block that i created, see picture attached. look at the last line of text.&lt;BR /&gt;
&lt;BR /&gt;
is there a way to synchronize the block? that way the position will be reset.&lt;BR /&gt;
&lt;BR /&gt;
why is it this .net controlling autocad so much more complicated than the com programming? so much work just to insert a block. it's like this doesn't make sense. i already created the block in the drawing, and you have to re-add all attributes again when you insert the block. i didn't know that attribute definition and attribute reference are different things. when you do stuff in autocad you never have to pay attention to there things. there is only one object: attribute definition. &lt;BR /&gt;
&lt;BR /&gt;
all i am trying to do is let the program go through couple thousand drawings, get the revision number, updated it by one, insert a block which i have to remake because people don't know what they are doing and do strange stuff to show the drawing revision text. i am doing all these by "db.ReadDwgFile" which doesn't open the drawing, or else this program will take forever to run consider each drawing has to be opened in editor. to make this in com would be so easy, i just want to learn this .net thing. seems 100 times more powerful.&lt;BR /&gt;
&lt;BR /&gt;
thanks a lot.</description>
      <pubDate>Sat, 09 May 2009 22:41:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484914#M70647</guid>
      <dc:creator>wang890</dc:creator>
      <dc:date>2009-05-09T22:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: insert a block with attribute doesn't show up</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484915#M70648</link>
      <description>figured this one out, have to use new matrix, was using the matrix from block&lt;BR /&gt;
&lt;BR /&gt;
 oAttRef.SetAttributeFromBlock(oAttDef, New Matrix3d)&lt;BR /&gt;
&lt;BR /&gt;
how come the program only works when i have 1 layout in drawing, once i have 2 layouts the block is inserted to each layout, but invisible like the first time. what i did is for each layout:&lt;BR /&gt;
&lt;BR /&gt;
 Dim br As New BlockReference(New Point3d..........&lt;BR /&gt;
&lt;BR /&gt;
Dim revBtr As BlockTableRecord = trans.GetObject(br.BlockTableRecord, OpenMode.ForRead)&lt;BR /&gt;
&lt;BR /&gt;
For Each id As ObjectId In revBtr&lt;BR /&gt;
&lt;BR /&gt;
'here i go through each and find attribute definition and change the textstring. &lt;BR /&gt;
&lt;BR /&gt;
Next&lt;BR /&gt;
&lt;BR /&gt;
br.AttributeCollection.AppendAttribute(oAttRef)&lt;BR /&gt;
&lt;BR /&gt;
trans.AddNewlyCreatedDBObject(oAttRef, True)&lt;BR /&gt;
&lt;BR /&gt;
trans.AddNewlyCreatedDBObject(br, True)&lt;BR /&gt;
&lt;BR /&gt;
maybe because i add a new object everytime? there's only 1 block with that name and i am trying to add many times?</description>
      <pubDate>Sat, 09 May 2009 23:46:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484915#M70648</guid>
      <dc:creator>wang890</dc:creator>
      <dc:date>2009-05-09T23:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: insert a block with attribute doesn't show up</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484916#M70649</link>
      <description>public bool AppendAttribRefToBlockRef(ObjectId blockdefid, ObjectId blockrefid, List&lt;STRING&gt; attribs)&lt;BR /&gt;
        {&lt;BR /&gt;
            try&lt;BR /&gt;
            {&lt;BR /&gt;
                BlockTableRecord blkdef = (BlockTableRecord)m_Transaction.GetObject(blockdefid, OpenMode.ForRead);&lt;BR /&gt;
                int i = 0;&lt;BR /&gt;
                if (blkdef.HasAttributeDefinitions)&lt;BR /&gt;
                {&lt;BR /&gt;
                    BlockReference blkref = (BlockReference)m_Transaction.GetObject(blockrefid, OpenMode.ForWrite);&lt;BR /&gt;
                    foreach (ObjectId id in blkdef)&lt;BR /&gt;
                    {&lt;BR /&gt;
                        DBObject ent = GetObject(id, OpenMode.ForRead);&lt;BR /&gt;
                        if (ent.GetType() == typeof(AttributeDefinition))&lt;BR /&gt;
                        {&lt;BR /&gt;
                            AttributeDefinition attdef = (AttributeDefinition)ent;&lt;BR /&gt;
                            AttributeReference attref = new AttributeReference();&lt;BR /&gt;
                            attref.SetAttributeFromBlock(attdef, blkref.BlockTransform);&lt;BR /&gt;
                            if (attdef.Justify == AttachmentPoint.BaseLeft)&lt;BR /&gt;
                                attref.Position = attdef.Position.TransformBy(blkref.BlockTransform);&lt;BR /&gt;
                            else&lt;BR /&gt;
                                attref.AlignmentPoint = attdef.AlignmentPoint.TransformBy(blkref.BlockTransform);&lt;BR /&gt;
                            if (attref.IsMTextAttribute)&lt;BR /&gt;
                                attref.UpdateMTextAttribute();&lt;BR /&gt;
                            if (i &amp;lt; attribs.Count)&lt;BR /&gt;
                                attref.TextString = attribs[i++];&lt;BR /&gt;
                            else&lt;BR /&gt;
                                attref.TextString = attdef.TextString;&lt;BR /&gt;
                            blkref.AttributeCollection.AppendAttribute(attref);&lt;BR /&gt;
                            m_Transaction.AddNewlyCreatedDBObject(attref, true);&lt;BR /&gt;
                        }&lt;BR /&gt;
                    }&lt;BR /&gt;
                }&lt;BR /&gt;
                return true;&lt;BR /&gt;
            }&lt;BR /&gt;
            catch&lt;BR /&gt;
            { }&lt;BR /&gt;
            return false;&lt;BR /&gt;
        }&lt;/STRING&gt;</description>
      <pubDate>Mon, 11 May 2009 07:04:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484916#M70649</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-05-11T07:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: insert a block with attribute doesn't show up</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484917#M70650</link>
      <description>after 30 hours of playing around. i finally found the problem and i can say that i am sure it is the bug with the API.&lt;BR /&gt;
&lt;BR /&gt;
so i am doing this whole thing by accessing the db like this:&lt;BR /&gt;
&lt;BR /&gt;
     Dim db As Database = New Database(False, False)&lt;BR /&gt;
      db.ReadDwgFile(TestPath, IO.FileShare.ReadWrite, True, "")&lt;BR /&gt;
&lt;BR /&gt;
instead of &lt;BR /&gt;
&lt;BR /&gt;
     Dim db As Database = New Database(False, False)&lt;BR /&gt;
        db = Application.DocumentManager.MdiActiveDocument.Database&lt;BR /&gt;
&lt;BR /&gt;
i tried open the drawing first in editor then the block is perfect, for some reason if i open the database by "readingdwgfile" then the block insertion is always lower left. is there a way to call an update block withing the API, like synchronize block in Cad.&lt;BR /&gt;
&lt;BR /&gt;
thank you</description>
      <pubDate>Wed, 13 May 2009 01:26:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2484917#M70650</guid>
      <dc:creator>wang890</dc:creator>
      <dc:date>2009-05-13T01:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: insert a block with attribute doesn't show up</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2837455#M70651</link>
      <description>&lt;P&gt;wang,&lt;/P&gt;&lt;P&gt;could you tell me how did you make the attribute show up?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2010 05:50:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-block-with-attribute-doesn-t-show-up/m-p/2837455#M70651</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-11-29T05:50:39Z</dc:date>
    </item>
  </channel>
</rss>

