Insert block with parameters and attributes

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone
I am looking for a long time in a solution to inserting block using vb.net. I need to insert a block with parameters and attributes. My dynamic block has three parameters and two attributes, but I only can insert the block and send the parameters using vb.net. How can I send the attributes to the block if the block is dynamic?.
The initial code to insert the block:
Dim acdoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim accurdb As Database = acdoc.Database
Using acdoc.LockDocument()
Using acTrans As Transaction = accurdb.TransactionManager.StartTransaction()
' Open the Block table for read
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(accurdb.BlockTableId, OpenMode.ForRead)
Dim blkRecId As ObjectId = ObjectId.Null
blkRecId = acBlkTbl(nombrebloque)
' Insert the block into the current space
If blkRecId <> ObjectId.Null Then
Using acBlkRef As New BlockReference(New Point3d(0, 0, 0), blkRecId)
Dim acCurSpaceBlkTblRec As BlockTableRecord
acCurSpaceBlkTblRec = acTrans.GetObject(accurdb.CurrentSpaceId, OpenMode.ForWrite)
acCurSpaceBlkTblRec.AppendEntity(acBlkRef)
'**********PROPIEDADES*********
Dim pc As DynamicBlockReferencePropertyCollection = acBlkRef.DynamicBlockReferencePropertyCollection
' MsgBox("añadido a tblrec")
acBlkRef.Layer = capa
acTrans.AddNewlyCreatedDBObject(acBlkRef, True)
For Each prop As DynamicBlockReferenceProperty In pc
If prop.PropertyName = "pkini_origen" Then
prop.Value = xiniorigen
End If
If prop.PropertyName = "pkini_destino" Then
prop.Value = xinidestino
End If
[...]
Thank you
Please, excuse my bad english...