<?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 VB.NET block with attributes problem in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/vb-net-block-with-attributes-problem/m-p/9865666#M17964</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm trying to work with block + attributes, I can create it but if I insert it by .net hte block don't have attributes, if I&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;insert it manual&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;ly the attributes are ok why?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Senzanome.jpg" style="width: 521px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/843691i2964851301B834C3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Senzanome.jpg" alt="Senzanome.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;&amp;lt;CommandMethod("AddingAttributeToABlock")&amp;gt;
            Public Sub AddingAttributeToABlock()
                ' Get the current database and start a transaction
                Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
                Dim acCurDb As Database = acDoc.Database
                Dim blkRecId As ObjectId = ObjectId.Null

                Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
                    ' Open the Block table for read
                    Dim acBlkTbl As BlockTable
                    acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)

                    If Not acBlkTbl.Has("CircleBlockWithAttributes") Then
                        Using acBlkTblRec As New BlockTableRecord
                            acBlkTblRec.Name = "CircleBlockWithAttributes"

                            ' Set the insertion point for the block
                            acBlkTblRec.Origin = New Point3d(0, 0, 0)

                            ' Add a circle to the block
                            Using acCirc As New Circle
                                acCirc.Center = New Point3d(0, 0, 0)
                                acCirc.Radius = 2

                                acBlkTblRec.AppendEntity(acCirc)

                                ' Add an attribute definition to the block
                                Using acAttDef As New AttributeDefinition
                                    acAttDef.Position = New Point3d(0, 0, 0)
                                    acAttDef.Verifiable = True
                                    'acAttDef.Visible = False
                                    acAttDef.Prompt = "Door #: "
                                    acAttDef.Tag = "Door#"
                                    acAttDef.TextString = "DXX"
                                    acAttDef.Height = 1
                                    acAttDef.Justify = AttachmentPoint.MiddleCenter
                                    acAttDef.LockPositionInBlock = True
                                    acBlkTblRec.AppendEntity(acAttDef)

                                    acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForWrite)
                                    acBlkTbl.Add(acBlkTblRec)
                                    acTrans.AddNewlyCreatedDBObject(acBlkTblRec, True)

                                End Using
                            End Using
                            blkRecId = acBlkTblRec.Id
                        End Using
                    End If

                    Dim pPtRes As PromptPointResult
                    Dim pPtOpts As PromptPointOptions = New PromptPointOptions("")
                    '' Prompt for the start point
                    pPtOpts.Message = vbLf &amp;amp; "Enter the point: "
                    pPtRes = acDoc.Editor.GetPoint(pPtOpts)
                    Dim ptStart As Point3d = pPtRes.Value

                    '' Exit if the user presses ESC or cancels the command
                    If pPtRes.Status = PromptStatus.Cancel Then Exit Sub

                    ' Insert the block into the current space
                    If blkRecId &amp;lt;&amp;gt; ObjectId.Null Then
                        Using acBlkRef As New BlockReference(ptStart, blkRecId)

                            Dim acCurSpaceBlkTblRec As BlockTableRecord
                            acCurSpaceBlkTblRec = acTrans.GetObject(acCurDb.CurrentSpaceId, OpenMode.ForWrite)

                            acCurSpaceBlkTblRec.AppendEntity(acBlkRef)
                            acTrans.AddNewlyCreatedDBObject(acBlkRef, True)
                        End Using
                    End If

                    ' Save the new object to the database
                    acTrans.Commit()

                    ' Dispose of the transaction
                End Using
            End Sub

        End Class&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2020 19:53:34 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-11-12T19:53:34Z</dc:date>
    <item>
      <title>VB.NET block with attributes problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-block-with-attributes-problem/m-p/9865666#M17964</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm trying to work with block + attributes, I can create it but if I insert it by .net hte block don't have attributes, if I&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;insert it manual&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;ly the attributes are ok why?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Senzanome.jpg" style="width: 521px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/843691i2964851301B834C3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Senzanome.jpg" alt="Senzanome.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;&amp;lt;CommandMethod("AddingAttributeToABlock")&amp;gt;
            Public Sub AddingAttributeToABlock()
                ' Get the current database and start a transaction
                Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
                Dim acCurDb As Database = acDoc.Database
                Dim blkRecId As ObjectId = ObjectId.Null

                Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
                    ' Open the Block table for read
                    Dim acBlkTbl As BlockTable
                    acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)

                    If Not acBlkTbl.Has("CircleBlockWithAttributes") Then
                        Using acBlkTblRec As New BlockTableRecord
                            acBlkTblRec.Name = "CircleBlockWithAttributes"

                            ' Set the insertion point for the block
                            acBlkTblRec.Origin = New Point3d(0, 0, 0)

                            ' Add a circle to the block
                            Using acCirc As New Circle
                                acCirc.Center = New Point3d(0, 0, 0)
                                acCirc.Radius = 2

                                acBlkTblRec.AppendEntity(acCirc)

                                ' Add an attribute definition to the block
                                Using acAttDef As New AttributeDefinition
                                    acAttDef.Position = New Point3d(0, 0, 0)
                                    acAttDef.Verifiable = True
                                    'acAttDef.Visible = False
                                    acAttDef.Prompt = "Door #: "
                                    acAttDef.Tag = "Door#"
                                    acAttDef.TextString = "DXX"
                                    acAttDef.Height = 1
                                    acAttDef.Justify = AttachmentPoint.MiddleCenter
                                    acAttDef.LockPositionInBlock = True
                                    acBlkTblRec.AppendEntity(acAttDef)

                                    acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForWrite)
                                    acBlkTbl.Add(acBlkTblRec)
                                    acTrans.AddNewlyCreatedDBObject(acBlkTblRec, True)

                                End Using
                            End Using
                            blkRecId = acBlkTblRec.Id
                        End Using
                    End If

                    Dim pPtRes As PromptPointResult
                    Dim pPtOpts As PromptPointOptions = New PromptPointOptions("")
                    '' Prompt for the start point
                    pPtOpts.Message = vbLf &amp;amp; "Enter the point: "
                    pPtRes = acDoc.Editor.GetPoint(pPtOpts)
                    Dim ptStart As Point3d = pPtRes.Value

                    '' Exit if the user presses ESC or cancels the command
                    If pPtRes.Status = PromptStatus.Cancel Then Exit Sub

                    ' Insert the block into the current space
                    If blkRecId &amp;lt;&amp;gt; ObjectId.Null Then
                        Using acBlkRef As New BlockReference(ptStart, blkRecId)

                            Dim acCurSpaceBlkTblRec As BlockTableRecord
                            acCurSpaceBlkTblRec = acTrans.GetObject(acCurDb.CurrentSpaceId, OpenMode.ForWrite)

                            acCurSpaceBlkTblRec.AppendEntity(acBlkRef)
                            acTrans.AddNewlyCreatedDBObject(acBlkRef, True)
                        End Using
                    End If

                    ' Save the new object to the database
                    acTrans.Commit()

                    ' Dispose of the transaction
                End Using
            End Sub

        End Class&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 19:53:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-block-with-attributes-problem/m-p/9865666#M17964</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-12T19:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: VB.NET block with attributes problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-block-with-attributes-problem/m-p/9865722#M17965</link>
      <description>&lt;P&gt;Different from VBA/COM API used for inserting block reference (Model[Paper]Space.InsertBlock(....), if you have ever programmed in AutoCAD VBA, in Acad .NET API/ObjectARX API, you need to write code the add AttributeReference to the BlockReference explicitly. Something like:&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;'' Create new block reference here&lt;/P&gt;
&lt;P&gt;'' Append block reference into space&lt;/P&gt;
&lt;P&gt;'' Add block reference to Transaction&lt;/P&gt;
&lt;P&gt;'' Create attributereference&lt;/P&gt;
&lt;P&gt;For Each id As ObjectId in [theBlockTableRecord]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; If id.ObjectClass.DxfName.ToUpper()="ATTDEF" Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dim attDef=DirectCast(trans.GetObject(id, OpenMode.ForRead), AttributeDefinition)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If Not attDef.Constant Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dim att =New AttributeReference()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; att.SetAttributeFromBlock(attDef, [blkRef].BlockTransform)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; att.TextString="zzzzzzzz"&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [blkRef].AttributeCollection.AppendAttribute(att)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; trans.AddNewlyCreatedObject(att, True)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; End If&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; End If&lt;/P&gt;
&lt;P&gt;Next&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;trans. Commit()&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 20:21:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-block-with-attributes-problem/m-p/9865722#M17965</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2020-11-12T20:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: VB.NET block with attributes problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-block-with-attributes-problem/m-p/10598604#M17966</link>
      <description>&lt;P&gt;Your code is setting attribute visibility to false.&amp;nbsp; Set to true and it should be visible.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Sep 2021 04:30:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-block-with-attributes-problem/m-p/10598604#M17966</guid>
      <dc:creator>twmerren</dc:creator>
      <dc:date>2021-09-04T04:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: VB.NET block with attributes problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/vb-net-block-with-attributes-problem/m-p/10599274#M17967</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5363359"&gt;@twmerren&lt;/a&gt;&amp;nbsp;, what do you talk about? The OP's code not creating and adding AttributeReference to the BlockReference's AttributeCollection is the reason. No having AttributeReference created, how/where the OP's code can set Visible property? I think you must mis-read the OP's code where a line of code setting AttributeDefinition(!)'s Visible property, which is commented out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Sep 2021 14:40:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vb-net-block-with-attributes-problem/m-p/10599274#M17967</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2021-09-04T14:40:50Z</dc:date>
    </item>
  </channel>
</rss>

