Imports XCCLibrary
Imports SldWorks
Public Class SW_HLCt_Gratings
    Public Shared Sub BuildGrating()
        Dim exportTable As DataTable
        exportTable = GUI_Gratings_Data.Create_ExportTable()

        XCCBaseClass.newDesign()
        ExternalClass.PopulateTamplateXMLGroup()

        Dim inst_ As Integer
        Dim parentID As Integer = 0
        Dim gratingParameters As DataRow = exportTable.Rows(0)
        inst_ = ExternalClass.instantiate_parts(parentID, gratingParameters("TYPE"), "") ' Ange pressure_welded eller type A, Serrated?
        ExternalClass.modify_parameter_value("DP_GRATING_WIDTH", inst_, gratingParameters("WIDTH"))
        ExternalClass.modify_parameter_value("DP_GRATING_LENGTH", inst_, gratingParameters("LENGTH"))
        ExternalClass.modify_parameter_value("DP_LOADBAR_THICKNESS", inst_, gratingParameters("LOADBAR_THICKNESS"))
        ExternalClass.modify_parameter_value("DP_LOADBAR_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
        ExternalClass.modify_parameter_value("DP_LOADBAR_SPACING", inst_, gratingParameters("LOADBAR_SPACING"))
        ExternalClass.modify_parameter_value("DP_CROSSBAR_SPACING", inst_, gratingParameters("CROSSBAR_SPACING"))

        If gratingParameters("TYPE") = "pressure_welded" Then
            ExternalClass.modify_parameter_value("DP_CROSSBAR_DIAMETER", inst_, gratingParameters("CROSSBAR_DIAMETER"))
        Else
            ExternalClass.modify_parameter_value("DP_CROSSBAR_THICKNESS", inst_, gratingParameters("CROSSBAR_THICKNESS"))
            ExternalClass.modify_parameter_value("DP_CROSSBAR_HEIGHT", inst_, gratingParameters("CROSSBAR_HEIGHT"))
        End If

        importClass.copyGroupsByDataSet(ExternalClass.groupds_new)
        Dim grNr = groupClass.NewGroupID
        Dim designTable = designModel.selectDesign("*")
        Dim designName = designTable.rows(0)("designName")
        groupClass.InstantiateGroup(designName, grNr, "START")
    End Sub

End Class
