<?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 Block - Workflow? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435615#M55926</link>
    <description>&lt;P&gt;Constant Attributes?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's that? Can you tell me more please.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Apr 2012 21:00:59 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-04-27T21:00:59Z</dc:date>
    <item>
      <title>Insert Block - Workflow?</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435307#M55921</link>
      <description>&lt;P&gt;Am I along the correct workflow path here?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to insert a drawing as a block into my current drawing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before I start writing code I want to make sure I understand the steps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Open Transaction&lt;/P&gt;&lt;P&gt;Wblock Drawing to Temp Database&lt;/P&gt;&lt;P&gt;Now have my New BlockTableRecord Object&amp;nbsp;&lt;/P&gt;&lt;P&gt;Copy BlockTableRecord to ActiveDwg.Database&lt;/P&gt;&lt;P&gt;Create New BlockReference&lt;/P&gt;&lt;P&gt;Add attributes&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set Scale Properties&lt;/P&gt;&lt;P&gt;Set Insertion Point&lt;/P&gt;&lt;P&gt;Set Rotation&amp;nbsp;&lt;/P&gt;&lt;P&gt;Append BlockReference to Database&lt;/P&gt;&lt;P&gt;Commit Transaction&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I missing any of the steps?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this how I would imidate the old VBA modelspace.insertblock(myPoint, "C:\path\path\path\block.dwg",1,1,1,0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 18:14:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435307#M55921</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-27T18:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block - Workflow?</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435411#M55922</link>
      <description>&lt;P&gt;What about &lt;STRONG&gt;Database.Insert&lt;/STRONG&gt; method?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 19:05:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435411#M55922</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-04-27T19:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block - Workflow?</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435495#M55923</link>
      <description>&lt;P&gt;Yes!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that will work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AutoCAD help says:&amp;nbsp;&lt;/P&gt;&lt;P&gt;This function mimics the AutoCAD INSERT command. First a new block table record is created in the database executing this function. This new block table record is given the name pointed to by &lt;SPAN&gt;blockName&lt;/SPAN&gt;. Then, all the Model Space entities in the database pointed to by &lt;SPAN&gt;dataBase&lt;/SPAN&gt; are copied into the new block table record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 20:05:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435495#M55923</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-27T20:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block - Workflow?</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435539#M55924</link>
      <description>&lt;P&gt;Here's some code for people after me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Shared Sub InsertInstrumentBlock()
            Dim gstrc_InstrumentBubbleBlock_FilePath As String = "C:\myblock.dwg"
            Dim BlockName As String = "Field Instrument"

            Dim myDwg As Document = Application.DocumentManager.MdiActiveDocument
            Using myTrans As Transaction = myDwg.TransactionManager.StartTransaction

                '&amp;lt;&amp;lt;Get Block From Drawing&amp;gt;&amp;gt;
                'Read Block Drawing's Database
                Dim BlkDwgDB As New Database(False, False)
                BlkDwgDB.ReadDwgFile(gstrc_InstrumentBubbleBlock_FilePath, System.IO.FileShare.Read, True, "")

                'Insert Block, Get ObjectID
                Dim id As ObjectId = mydwg.Database.Insert(BlockName, BlkDwgDB, False)

                '&amp;lt;&amp;lt;Insert BlockDefinition Into Specific Place on ModelSpace/PaperSpace&amp;gt;&amp;gt;
                'Open the database for Write
                Dim myBT As BlockTable = myDwg.Database.BlockTableId.GetObject(OpenMode.ForRead)
                Dim myModelSpace As BlockTableRecord = myBT(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)

                'Block Table Record (Block Definitions)
                Dim myBlockDef As BlockTableRecord = id.GetObject(OpenMode.ForWrite)

                Dim InsPt As New Point3d(0,0,0)
                

                'Block References (Insertions of Blocks into Drawing Space)
                Dim myBlockRef As New DatabaseServices.BlockReference(InsPt, myBT(BlockName))
                myBlockRef.ScaleFactors = New Geometry.Scale3d(1, 1, 1)

                myModelSpace.AppendEntity(myBlockRef)
                myTrans.AddNewlyCreatedDBObject(myBlockRef, True)

                'Append Attribute References to the BlockReference
                Dim myAttColl As DatabaseServices.AttributeCollection
                Dim myEntID As ObjectId
                Dim myEnt As DatabaseServices.Entity

                myAttColl = myBlockRef.AttributeCollection
                For Each myEntID In myBlockDef
                    myEnt = myEntID.GetObject(OpenMode.ForWrite)
                    If TypeOf myEnt Is DatabaseServices.AttributeDefinition Then
                        Dim myAttDef As DatabaseServices.AttributeDefinition = _
                       CType(myEnt, AttributeDefinition)
                        Dim myAttRef As New DatabaseServices.AttributeReference
                        myAttRef.SetAttributeFromBlock(myAttDef, myBlockRef.BlockTransform)
                        myAttColl.AppendAttribute(myAttRef)
                        myTrans.AddNewlyCreatedDBObject(myAttRef, True)
                    End If
                Next

                'Commit the Transaction
                myTrans.Commit()
            End Using




        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 20:29:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435539#M55924</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-27T20:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block - Workflow?</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435599#M55925</link>
      <description>&lt;P&gt;&lt;SPAN class="short_text"&gt;&lt;SPAN class="hps"&gt;You forgot&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;to skip&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the constant&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;attributes&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 20:53:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435599#M55925</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-04-27T20:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block - Workflow?</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435615#M55926</link>
      <description>&lt;P&gt;Constant Attributes?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's that? Can you tell me more please.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 21:00:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435615#M55926</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-27T21:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block - Workflow?</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435617#M55927</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Constant Attributes?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's that? Can you tell me more please.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If &lt;STRONG&gt;AttributeDefinition.Constant = True&lt;/STRONG&gt; then you have not add this attribute to attribute collection.&lt;/P&gt;
&lt;P&gt;More detailes about constant attribute definition: &lt;A href="http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-5142.htm,topicNumber=d0e197887" target="_blank"&gt;http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-5142.htm,topicNumber=d0e197887&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Also read: &lt;A href="http://forums.autodesk.com/t5/NET/How-to-Preserve-Constat-Attributes-on-BlockReference/m-p/2634989/highlight/true#M17866" target="_blank"&gt;http://forums.autodesk.com/t5/NET/How-to-Preserve-Constat-Attributes-on-BlockReference/m-p/2634989/highlight/true#M17866&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 21:12:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-workflow/m-p/3435617#M55927</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2012-04-27T21:12:47Z</dc:date>
    </item>
  </channel>
</rss>

