Get Panel Properties by VBA

muhammad_hasan88NXQ
Enthusiast
Enthusiast

Get Panel Properties by VBA

muhammad_hasan88NXQ
Enthusiast
Enthusiast

Hai Guys, 

I am trying to get the available panel properties from the robot and try to updated it. 

I am getting following error in the highlighted line in the snip please help.

muhammad_hasan88NXQ_0-1709275067139.png

 

0 Likes
Reply
Accepted solutions (1)
422 Views
5 Replies
Replies (5)

Stephane.kapetanovic
Advisor
Advisor

hi @muhammad_hasan88NXQ 

GetAvailableNames returns a RobotNamesArray as follow

Dim LabelServer As RobotLabelServer = RobApp.Project.Structure.Labels
Dim ThicknessNames As IRobotNamesArray = LabelServer.GetAvailableNames(I_LT_PANEL_THICKNESS)
For k = 1 To ThicknessNames.Count
    Dim Name As String = ThicknessNames.Get(k)
   '[...]
Next

if you want a label, use a syntax like

Dim ThicknessLabel As RobotLabel = LabelServer.Get(I_LT_PANEL_THICKNESS, Name)

could you tell me about your project ?

Best Regards

 

see also : https://forums.autodesk.com/t5/robot-structural-analysis-forum/get-panel-thickness-with-api/td-p/118...

 

 

 

 

muhammad_hasan88NXQ
Enthusiast
Enthusiast
Thank you for your support, Figured out first 3 lines myself with the help of similar post on how to delet supports with python, but thanks for the name thing couldn't figure that out.And yah I need the exact label as in robot as i am planing to update the panel properties after getting it.

0 Likes

muhammad_hasan88NXQ
Enthusiast
Enthusiast

I have tried your code and tailred it to my requirement. I am getting following error.

muhammad_hasan88NXQ_0-1709290835989.png

My full code :

Public Sub GetPanelProperties2()

'To check robot is open
Set robapp = New RobotApplication
If Not robapp.Project.IsActive Or robapp.Project.Type <> I_PT_SHELL Then
MsgBox "Open Robot Model", vbExclamation
Exit Sub
End If
robapp.Visible = True
robapp.Interactive = 1
robapp.UserControl = True

'Get the all the panel properties from robot function
Dim ThkSrv As RobotLabelServer
Set ThkSrv = robapp.Project.Structure.Labels
' Get the number of panel properties
Dim ThkNames As IRobotNamesArray
Set ThkNames = ThkSrv.GetAvailableNames(I_LT_PANEL_THICKNESS)
Thkcount = ThkNames.count

Dim ThkName As String, MatName As String, t1 As Double, t2 As Double, t3 As Double
Dim THData As RobotThicknessData
Dim HomoThickData As RobotThicknessHomoData

For i = 1 To Thkcount
Dim Name As String
Set Name = ThkNames.Get(K)
Cells(i + 2, 1) = ThkSrv.GetLabel(I_LT_PANEL_THICKNESS).Name
Set THData = Obj.GetLabel(I_LT_PANEL_THICKNESS).Data
Cells(i + 2, 2) = THData.MaterialName

If (THData.ThicknessType = I_TT_HOMOGENEOUS) Then
Set HomoThickData = THData.Data
Select Case HomoThickData.Type
Case I_THT_CONSTANT
Cells(i + 2, 3) = HomoThickData.ThickConst
Case I_THT_VARIABLE_ALONG_LINE
With HomoThickData
Cells(i + 2, 3) = .Thick1
Cells(i + 2, 4) = .Thick2
End With
Case I_THT_VARIABLE_ON_PLANE
With HomoThickData
Cells(i + 2, 3) = .Thick1
Cells(i + 2, 4) = .Thick2
Cells(i + 2, 5) = .Thick3
End With
End Select
End If
Next i

End Sub

 

My Intention is to get panel propteries and then change them and update the same in the robot. 

0 Likes

Stephane.kapetanovic
Advisor
Advisor
Accepted solution

hi @muhammad_hasan88NXQ 

to finish the process of collecting the thicknesses of the available thicknesses see the code below.

You will then need to collect the thicknesses applied to your objects.

Public Sub GetPanelProperties3()
  Dim RobApp As RobotApplication
  Set RobApp = New RobotApplication
  
  Dim Labels As RobotLabelServer, ThkNames As IRobotNamesArray
  Dim THData As RobotThicknessData, HomoThickData As RobotThicknessHomoData
  Dim ThkName As String, MatName As String
  
  Set Labels = RobApp.Project.Structure.Labels
  Set ThkNames = Labels.GetAvailableNames(I_LT_PANEL_THICKNESS): Thkcount = ThkNames.Count
  For i = 1 To Thkcount
    ThkName = ThkNames.Get(i)
    If Labels.Exist(I_LT_PANEL_THICKNESS, ThkName) <> 0 Then
      Set THData = Labels.Get(I_LT_PANEL_THICKNESS, ThkName).Data
      If THData.ThicknessType = I_TT_HOMOGENEOUS Then
        With THData: Set HomoThickData = .Data: MatName = .MaterialName: End With
        With HomoThickData
          Select Case .Type
            Case I_THT_CONSTANT:            Tb = Array(ThkName, MatName, .ThickConst)
            Case I_THT_VARIABLE_ALONG_LINE: Tb = Array(ThkName, MatName, .Thick1, .Thick2)
            Case I_THT_VARIABLE_ON_PLANE:   Tb = Array(ThkName, MatName, .Thick1, .Thick2, .Thick3)
          End Select
        End With
        j = j + 1: For k = 0 To UBound(Tb): Cells(j, k + 1) = Tb(k): Next k
      End If
    End If
  Next i
  Set RobApp = Nothing
End Sub

Best Regards

 

 

muhammad_hasan88NXQ
Enthusiast
Enthusiast
Thank you, let me try and get back to you