Message 1 of 10
Dynamic Block Point Parameter Visibility
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I Posted this at the end of a post that had a solution so I don't think anyone looked at. Sorry for posting it again.
http://adndevblog.typepad.com/autocad/2012/05/accessing-visible-entities-in-a-dynamic-block.html
Hi I'm having trouble with the code in the suggested solution above. 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 any suggestions would be much appreciated.
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