Hi Frank,
You wanted to get a translation from the LISP to VB.NET, what should I say, the codesippet you showed today morning does nothing on my pc/my Civil3D. However I could imagine what it should do: list all variables within a dictionary.
Look to my code, it takes the NOD, looks for a "AEC_VARS" item, goes through the collection of subobjects and list all the properties (name, type, value) from them. The output to a messagebox is quite ill because theres not enough place to show all properties from all records, you could change it to whatever you want, write a file or do just a debug-breakpoint and view it.
What you can see that for me in Civil3D I find a var "LinearUnit" within the item "AEC_VARS_DWG_SETUP", so my hope is you see it in your ACA also and at least you can modify it.
<Autodesk.AutoCAD.Runtime.CommandMethod("ADESK_listAecVars")> _
Public Shared Sub ADESK_getCivilUnits()
Dim tAcadDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim tAcadDocLock As DocumentLock = Nothing
Dim tTrAct As Transaction = Nothing
Dim tListAllVarsStr As String = ""
Try
tAcadDoc = Application.DocumentManager.MdiActiveDocument
tTrAct = tAcadDoc.TransactionManager.StartTransaction
Dim tNOD As DBDictionary = CType(tTrAct.GetObject(tAcadDoc.Database.NamedObjectsDictionaryId, OpenMode.ForRead), DBDictionary)
If tNOD.Contains("AEC_VARS") Then
Dim tObjID As ObjectId = CType(tNOD.Item("AEC_VARS"), ObjectId)
If (tObjID.IsValid) AndAlso (Not tObjID.IsErased) Then
Dim tDBObj As DBDictionary = CType(tTrAct.GetObject(tObjID, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead), DBDictionary)
If tDBObj.Count > 0 Then
Dim tEnum As DbDictionaryEnumerator = tDBObj.GetEnumerator
Do While tEnum.MoveNext
tListAllVarsStr &= "DbDict: " & tEnum.Key & vbNewLine
Dim tSubObj As DBObject = tTrAct.GetObject(tEnum.Value, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
tListAllVarsStr &= listProperties(tSubObj)
tListAllVarsStr &= vbNewLine
Loop
End If
Debug.Print("")
End If
End If
Call MsgBox(tListAllVarsStr)
Catch ex As Exception
MsgBox("Error occured" & vbNewLine & ex.Message)
Finally
If tTrAct IsNot Nothing Then tTrAct.Dispose() : tTrAct = Nothing
If tAcadDocLock IsNot Nothing Then tAcadDocLock.Dispose() : tAcadDocLock = Nothing
End Try
End Sub
''' <summary>listProperties does a MINIMAL listing of the property-values of an object
''' 'it does not evaluate any arrays, enumerations, subobjects, ...
''' </summary>
''' <param name="Obj"></param>
''' <returns>a string listing prop-name, prop-type, prop-value</returns>
''' <remarks></remarks>
Private Shared Function listProperties(ByVal Obj As Object) As String
Dim tRetVal As String = ""
If Obj IsNot Nothing Then
Dim tPropDefs() As PropertyInfo = Obj.GetType.GetProperties()
For Each tPropDef As PropertyInfo In tPropDefs
Dim tValStr As String = vbTab & tPropDef.Name & vbTab & "(" & tPropDef.PropertyType.FullName & "):" & vbTab
Try
Dim tVal As Object = tPropDef.GetValue(Obj, Nothing)
If tVal IsNot Nothing Then
tValStr &= tVal.ToString
Else
tValStr &= "<nothing>"
End If
Catch ex As Exception
tValStr &= "<error evaluating>"
End Try
tRetVal &= tValStr & vbNewLine
Next
End If
Return tRetVal
End Function
HTH, - alfred -
------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ...
blog.ish-solutions.at ...
LinkedIn ...
CDay 2026------------------------------------------------------------------------------------
(not an Autodesk consultant)