DigiPara Liftdesigner LDX API
Loading...
Searching...
No Matches
User Data

API method: ILDXSheets5.UserData

Treename: Sheets.

 ' from Samples/Src/LDXAPIExamples/Example_LDXSheets.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc, APIHelpModes.InputParaDesktopWithOtherFileName, "LD API example.dwg"}, "Sheets.", "LDXSheets~UserData", "User Data")>
 Public Shared Sub UserData(ByRef ldxDocument As DigiPara.LDX.LDXDocument, ByVal SheetFilePath As String)

     If ldxDocument.Sheets Is Nothing Then
         MsgBox("Sheets not found!")
         Exit Sub
     End If

     ' you can store arrays of strings as user data under your custom key on sheets
     With ldxDocument.Sheets
         ' here, we first try to read existing user data
         Dim restore = .UserData("MY_USER_DATA")

         If IsNothing(restore) Then
             System.Windows.Forms.MessageBox.Show("No user data set", "User Data")
             ' store empty user data
             .UserData("MY_USER_DATA") = {}
         ElseIf restore.Count = 0 Then
             System.Windows.Forms.MessageBox.Show("Empty user data set", "User Data")
             ' store actual user data
             .UserData("MY_USER_DATA") = {"A", "B"}
         Else
             System.Windows.Forms.MessageBox.Show($"User data found: ({String.Join(", ", restore)})", "User Data")
             ' clear
             .UserData("MY_USER_DATA") = Nothing
         End If

     End With

 End Sub