Quantcast
Viewing all articles
Browse latest Browse all 14319

Modify Dynamic Block Properties before Jig

Hi, 

 

Is there a way to modify the properties of a dynamic block after the insert and before a jig?

 

I've tried a quite a few things but here is some code as a starting point. The blocks are affected by the change but not in a good way. The blocks have several parametric constraints. I wonder if this is part of the problem.

 

<CommandMethod("TestEntityJigger7")> _
    Public Shared Sub TestEntityJigger7_Method()
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim db As Database = HostApplicationServices.WorkingDatabase
        Dim pr As PromptResult = ed.GetString(vbLf & "Block name:")
        If pr.Status = PromptStatus.OK Then
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim bt As BlockTable = TryCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                Dim btr As BlockTableRecord = TryCast(tr.GetObject(bt(pr.StringResult), OpenMode.ForRead), BlockTableRecord)
                If btr IsNot Nothing Then
                    Dim br As New BlockReference(New Point3d(0, 0, 0), btr.ObjectId)
                    Dim pc As DynamicBlockReferencePropertyCollection = br.DynamicBlockReferencePropertyCollection
                    For i = 0 To pc.Count - 1
                        Dim prop As DynamicBlockReferenceProperty = pc(i)
                        If prop.PropertyName = "A" Then prop.Value = 1000.0#
                        If prop.PropertyName = "B" Then prop.Value = 2000.0#
                    Next
                    pc.Dispose()
                    If BlockMovingRotating.Jig(br) Then
                        Dim modelspace As BlockTableRecord = TryCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
                        modelspace.AppendEntity(br)
                        tr.AddNewlyCreatedDBObject(br, True)
                        tr.Commit()
                    Else
                        tr.Abort()
                    End If
                End If
            End Using
        End If
    End Sub

 

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 14319

Trending Articles