See the top rated post in this thread. Click here

Results 1 to 7 of 7

Thread: Filtering for Dynamic Blocks using XData - Need help with XData.ASArray

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    2012-01
    Location
    Texas
    Posts
    40
    Login to Give a bone
    0

    Default Filtering for Dynamic Blocks using XData - Need help with XData.ASArray

    I am trying to filter for a dynamic block using xdata. I found this post by Kean Walmsley going over the process, but I haven't been able to make it work for me. The code he has is in C#, which I'm not familiar with (I code very rarely).

    This is what I have so far:

    Code:
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
    
    
            Using tr As Transaction = doc.TransactionManager.StartTransaction()
    
                Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForWrite)
    
                For Each bid In bt
                    Dim btr2 As BlockTableRecord = tr.GetObject(bid, OpenMode.ForWrite)
                    If Not btr2.Name = "PointMarker" AndAlso IsDBNull(btr2.XData) = False Then
                        Dim TypeValArr() As TypedValue = btr2.XData.AsArray
                        For i = 0 To TypeValArr.Length
                            Dim TypeVal As String = TypeValArr(i)
                            If TypeVal.GetTypeCode = DxfCode.ExtendedDataRegAppName Then
                                If TypeVal.ToString = "AcDbBlockRepBTag" Then
                                    For j = i + 1 To TypeValArr.Length
                                        TypeVal = TypeValArr(j)
                                        If TypeVal.GetTypeCode = DxfCode.ExtendedDataRegAppName Then
                                            i = j - 1
                                            Exit For
                                        End If
                                        If TypeVal.GetTypeCode = DxfCode.ExtendedDataHandle Then
                                            If TypeVal.ToString = "PointMarker" Then
                                                Dim blockref As BlockReference = btr2.Id.GetObject(OpenMode.ForWrite)
                                                Dim xpos As Double = blockref.Position.X
                                                Dim ypos As Double = blockref.Position.Y
                                                Dim zpos As Double = blockref.Position.Z
                                                Dim scalefactor As Double = blockref.ScaleFactors.X
                                                blockref.ScaleFactors() = New Scale3d(sf)
                                                Dim ac As AttributeCollection = blockref.AttributeCollection
                                                For Each att As ObjectId In ac
                                                    Dim attr As DBObject = att.GetObject(OpenMode.ForWrite)
                                                    If TypeOf attr Is AttributeReference Then
                                                        Dim ar As AttributeReference = att.GetObject(OpenMode.ForWrite)
                                                        ar.TransformBy(Matrix3d.Scaling(1 / scalefactor, New Point3d(xpos, ypos, zpos)))
                                                        ar.TransformBy(Matrix3d.Scaling(sf, New Point3d(xpos, ypos, zpos)))
                                                    End If
                                                Next
                                                i = TypeValArr.Length - 1
                                                Exit For
                                            End If
                                        End If
                                        j = j + 1
                                    Next
                                End If
                            End If
                            i = i + 1
                        Next
    
                    End If
                Next
    
    tr.Commit()
    
    End Using

    I am stuck on the "Dim TypeValArr As Array = btr2.XData.AsArray" part. It continually causes a fatal error when the code runs. Should I be declaring this differently?
    Last edited by apitcher799568; 2015-08-28 at 01:32 PM.

Similar Threads

  1. Filtering by Xdata
    By JasonSelf in forum AutoLISP
    Replies: 6
    Last Post: 2014-11-25, 10:30 AM
  2. Replies: 0
    Last Post: 2008-02-09, 01:06 PM
  3. xdata
    By san_k4 in forum VBA/COM Interop
    Replies: 3
    Last Post: 2005-09-19, 10:29 PM
  4. xdata
    By fletch97 in forum AutoLISP
    Replies: 1
    Last Post: 2005-08-31, 05:52 PM
  5. Possible xdata?
    By whdjr in forum AutoLISP
    Replies: 7
    Last Post: 2004-08-25, 03:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •