.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynamic Block Parameter Visibility

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
GeeHaa
995 Views, 3 Replies

Dynamic Block Parameter Visibility

Hi,

 

I need to know where to look to find if a point parameter is visible the the current visibility state of the dynamic block reference.

 

Thanks in advance

3 REPLIES 3
Message 2 of 4
Balaji_Ram
in reply to: GeeHaa

Hi,

 

Have you tried the code from this blog post ?

http://adndevblog.typepad.com/autocad/2012/05/accessing-visible-entities-in-a-dynamic-block.html



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
GeeHaa
in reply to: GeeHaa

Thanks,

 

This is what I was looking for.

Message 4 of 4
GeeHaa
in reply to: Balaji_Ram

Hi I'm having trouble with the code in the suggested solution. I translated it to VB.net and I am getting an error EntryPoint "?" not found in acdb19.dll. I'm using acdb19.dll because it couldn't find acdb18.dll

 

Thanks

 

Public Sub DynablockVisibilityStates()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
                        Dim per As PromptEntityResult = ed.GetEntity(vbLf + "Select Dynamic Block ")


            If per.Status <> PromptStatus.OK Then
                Return
            End If

            Using myTrans As Transaction = db.TransactionManager.StartTransaction()

                Dim ent As Entity = myTrans.GetObject(per.ObjectId, OpenMode.ForRead)
                Dim bref As BlockReference = Nothing
                If TypeOf ent Is BlockReference Then
                    bref = ent
                End If

                Dim bt As BlockTable = TryCast(myTrans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                               Dim btr As BlockTableRecord = myTrans.GetObject(bref.DynamicBlockTableRecord, OpenMode.ForRead)


                               If Not btr.IsDynamicBlock Then
                    ed.WriteMessage(vbLf & "Not a dynamic block :(")
                    Return
                End If
                If btr.ExtensionDictionary = Nothing Then
                    ed.WriteMessage(vbLf & "No ExtensionDictionary :(")
                    Return
                End If

                Dim dict As DBDictionary = TryCast(myTrans.GetObject(btr.ExtensionDictionary, OpenMode.ForRead), DBDictionary)
                If Not dict.Contains("ACAD_ENHANCEDBLOCK") Then
                    ed.WriteMessage(vbLf & "ACAD_ENHANCEDBLOCK Entry not found :(")
                    Return
                End If
                Dim graphId As ObjectId = dict.GetAt("ACAD_ENHANCEDBLOCK")
                Dim parameterIds As System.Collections.Generic.List(Of Object) = acdbEntGetObjects(graphId, 360)

                For Each parameterId As Object In parameterIds
                    Dim id As ObjectId = DirectCast(parameterId, ObjectId)

                    If id.ObjectClass.Name = "AcDbBlockVisibilityParameter" Then
                        Dim visibilityParam As System.Collections.Generic.List(Of TypedValue) = acdbEntGetTypedVals(id)
                        Dim enumerator As System.Collections.Generic.List(Of TypedValue).Enumerator = visibilityParam.GetEnumerator()

                        While enumerator.MoveNext()
                            If enumerator.Current.TypeCode = 303 Then
                                Dim group As String = DirectCast(enumerator.Current.Value, String)
                                enumerator.MoveNext()
                                Dim nbEntitiesInGroup As Integer = CInt(enumerator.Current.Value)
                                ed.WriteMessage((Convert.ToString(vbLf & " . Visibility Group: ") & group) + " Nb Entities in group: " + nbEntitiesInGroup)
                                For i As Integer = 0 To nbEntitiesInGroup - 1
                                    enumerator.MoveNext()
                                    Dim entityId As ObjectId = DirectCast(enumerator.Current.Value, ObjectId)
                                    Dim entity As Entity = TryCast(myTrans.GetObject(entityId, OpenMode.ForRead), Entity)
                                    ed.WriteMessage(vbLf & "    - " + entity.ToString() + " " + entityId.ToString())
                                Next

                            End If
                        End While


                        Exit For

                    End If
                Next
                myTrans.Commit()
            End Using

        End Sub



        Public Structure ads_name
            Private a As IntPtr
            Private b As IntPtr
        End Structure

        <Runtime.InteropServices.DllImport("acdb19.dll", CallingConvention:=System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint:="?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z")> _
        Public Shared Function acdbGetAdsName(ByRef name As ads_name, objId As ObjectId) As Integer
        End Function


        <Runtime.InteropServices.DllImport("acad.exe", CharSet:=System.Runtime.InteropServices.CharSet.Ansi, CallingConvention:=System.Runtime.InteropServices.CallingConvention.Cdecl, EntryPoint:="acdbEntGet")> _
        Public Shared Function acdbEntGet(ByRef ename As ads_name) As System.IntPtr
        End Function

        Private Function acdbEntGetObjects(id As ObjectId, dxfcode As Short) As System.Collections.Generic.List(Of Object)
            Dim result As New System.Collections.Generic.List(Of Object)()
            Dim name As New ads_name()
            Dim res As Integer = acdbGetAdsName(name, id)
            Dim rb As New ResultBuffer()
            Autodesk.AutoCAD.Runtime.Interop.AttachUnmanagedObject(rb, acdbEntGet(name), True)
            Dim iter As ResultBufferEnumerator = rb.GetEnumerator()

            While iter.MoveNext()
                Dim typedValue As TypedValue = CType(iter.Current, TypedValue)
                If typedValue.TypeCode = dxfcode Then
                    result.Add(typedValue.Value)
                End If
            End While

            Return result
        End Function

        Private Function acdbEntGetTypedVals(id As ObjectId) As System.Collections.Generic.List(Of TypedValue)
            Dim result As New System.Collections.Generic.List(Of TypedValue)()
            Dim name As New ads_name()
            Dim res As Integer = acdbGetAdsName(name, id)
            Dim rb As New ResultBuffer()
            Autodesk.AutoCAD.Runtime.Interop.AttachUnmanagedObject(rb, acdbEntGet(name), True)
            Dim iter As ResultBufferEnumerator = rb.GetEnumerator()

            While iter.MoveNext()
                result.Add(CType(iter.Current, TypedValue))
            End While

            Return result

        End Function



    End Class

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost