Sub AddMaterialType
dim objCalc
dim objMat
dim thickness
dim volume
dim objTable
dim weightfac
dim weight
set objTable = pdc.Database.OpenTable(pdcCondata,"SGMAT","SG_MATNR")
if objTable.Locate("SG_MATNR","RVS306") then
set objCalc = pdc.NewCalculation
set objMat = objCalc.MaterialList.AddComposedMaterial("RVS306",4) 'RVS306 added as sheet
thickness = 20 'mm
objMat.Description = "PLAAT-" & thickness & "MM"
objMat.Length = 1 'm
objMat.Width = 1 'm
volume = thickness / 1000 ' volume per m2
objMat.CostKind = objTable.GetField("SG_KSTSRT")
weigthfac = objTable.GetField("SG_SGEW")
weigth = 1000 * volume * weigthfac
objMat.PricePerUnit = volume * weigthfac * 1000 * objTable.GetField("SG_PRIJS")
objMat.SurfaceFactor = 2 '2 for sheets
objMat.Weight = weigth
objMat.WeightFact = weigth
objMat.UseStandardSize = false 'Sheet and block should be false, others are true
objMat.DefaultSize = "" 'Nothing for sheets
objMat.Scrap = objTable.GetField("SG_AFP")
objMat.SurCharge = objTable.GetField("SG_TSLP")
objMat.GrossPurPrice = objMat.PricePerUnit
objMat.PurDiscount = 0
objCalc.Save
set objMat = nothing
set objCalc = nothing
end if
set objTable = nothing
End Sub