Message 1 of 2
Getting and Updating thickness and thickness' name

Not applicable
11-28-2017
02:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello to everybody!
I would like to get and updating in excel thickness and thickness'name from the object selected.
I'm struggling with the following code:
To get both values:
Public Sub CommandButton1_Click() Set RobApp = New RobotApplication Dim RSelection As RobotSelection Set RSelection = RobApp.Project.Structure.Selections.Get(I_OT_OBJECT) Dim Obj As RobotObjObject RSelection.ExcludeText Bsel Dim MatLabel As RobotLabel Dim MatData As RobotMaterialData Dim THData As RobotThicknessData Dim HomoThickData As RobotThicknessHomoData Set Obj = RobApp.Project.Structure.Objects.Get(AllObjects.Get(ii).Number) With Range("b5:c6") .Clear .NumberFormat = "#0.0#0" End With Cells(5, 2) = "1000" If Obj.Main.GetGeometry.Type = I_GOT_CONTOUR Then Row = 6 Set THData = Obj.GetLabel(I_LT_PANEL_THICKNESS).Data If (THData.ThicknessType = I_TT_HOMOGENEOUS) Then Set HomoThickData = THData.Data If (HomoThickData.Type = I_THT_CONSTANT) Then Cells(Row, 2) = HomoThickData.ThickConst * 1000 End If End If End If Next ii End If Dim MatCol As RobotLabelCollection Set MatCol = RobApp.Project.Structure.Labels.GetMany(I_LT_MATERIAL) Row = 7 For I = 1 To MatCol.Count Cells(Row, 2) = MatCol.Get(I).Name Set MatLabel = MatCol.Get(I) Set MatData = MatLabel.Data Next I End Sub
to update:
Private Sub Button3_Click() Set RobApp = New RobotApplication If Not RobApp.Visible Then Set RobApp = Nothing MsgBox "Robot closed", vbOKOnly, "ERROR" Exit Sub Else RobApp.Interactive = False If (RobApp.Project.Type <> I_PT_PLATE) And (RobApp.Project.Type <> I_PT_SHELL) And (RobApp.Project.Type <> I_PT_BUILDING) Then MsgBox "Structure Type should be PLATE or SHELL", vbOKOnly, "ERROR" RobApp.Interactive = True Exit Sub End If Dim MatLabel As RobotLabel Dim MatData As RobotMaterialData Dim Row As Integer Dim Iter As Integer Dim ObjNumber As Integer Dim RNAM As RobotNamesArray Set RNAM = RobApp.Project.Structure.Labels.GetAvailableNames(I_LT_MATERIAL) Dim MATExist As Boolean Dim ChangeName As Boolean Dim THData As RobotThicknessData Dim THLabel As RobotLabel Dim HomoThickData As RobotThicknessHomoData THExist = False MATExist = False Row = 6 If THExist Then Set THLabel = Obj.GetLabel(I_LT_PANEL_THICKNESS) Set THData = THLabel.Data If (THData.ThicknessType = I_TT_HOMOGENEOUS) Then Set HomoThickData = THData.Data If (HomoThickData.Type = I_THT_CONSTANT) Then If Not IsNumeric(Cells(Row, 2)) Then MsgBox ("There is no numeric value in Cell(" + Str(Row) + "," + "C). Update aborted") Exit Sub End If If (HomoThickData.ThickConst <> CDbl(Cells(Row, 2))) Then If MsgBox("Defined thickness in label " + THName + " is " + Str(HomoThickData.ThickConst) + _ "." + vbNewLine + " Replace it by " + Str(Cells(Row, 2)) + "?", vbYesNo) = vbYes Then HomoThickData.ThickConst = Cells(Row, 2).Value / 1000 End If MATName = Cells(Row, 3).Value For IMat = 1 To RNAM.Count If (MATName = RNAM.Get(IMat)) Then MATExist = True Exit For End If Next IMat If (MATExist) Then If (THData.MaterialName <> Cells(Row, 3).Value) Then If MsgBox("Defined material in label " + THName + " is " + THData.MaterialName + _ "." + vbNewLine + " Replace it by " + MATName + "?", vbYesNo) = vbYes Then THData.MaterialName = MATName End If Else MsgBox "Material " + MATName + " does not exist in model. It will not be assinged to panel thickness" End If RobApp.Project.Structure.Labels.Store THLabel Else MsgBox ("Panel thickess label " + THName + " is not homogenuos thickness label." + vbNewLine + _ "It will not be updated") End If End If '''''''''''''''''''' Obj.SetLabel I_LT_PANEL_THICKNESS, THName Else If Not IsNumeric(Cells(Row, 2)) Then MsgBox ("There is no numeric value in Cell(" + Str(Row + 1) + "," + "C). Update aborted") Exit Sub End If MATName = Cells(Row, 3).Value For IMat = 1 To RNAM.Count If (MATName = RNAM.Get(IMat)) Then MATExist = True Exit For End If Next IMat If (MATExist) Then Set THLabel = RobApp.Project.Structure.Labels.Create(I_LT_PANEL_THICKNESS, THName) Set THData = THLabel.Data Set HomoThickData = THData.Data HomoThickData.Type = I_THT_CONSTANT HomoThickData.ThickConst = CDbl(Cells(Row, 2).Value / 1000) THData.MaterialName = MATName RobApp.Project.Structure.Labels.Store THLabel Obj.SetLabel I_LT_PANEL_THICKNESS, THName Else MsgBox "Material " + MATName + " does not exist in model. It will not be assinged to panel thickness." + vbNewLine + _ "Panel thickness " + THName + " will not be created and assigned to panel" End If End If End If End Sub