PdcMaterialList.AddComposedMaterial: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Declaration == | == Declaration == | ||
AddComposedMaterial(MaterialKind as String,ComposedMaterialType as Integer, Volume as | AddComposedMaterial(MaterialKind as String,ComposedMaterialType as Integer, Volume as Double, Surface as Double) as [[PdcMaterial]] | ||
== Description == | == Description == | ||
Line 10: | Line 10: | ||
* The first parameter determines the materialkind. | * The first parameter determines the materialkind. | ||
* The second parameter is composed material type, with the following options: | * The second parameter is composed material type, with the following options: | ||
0 - Piece | 0 - Piece<br /> | ||
1 - Meter (M) | 1 - Meter (M)<br /> | ||
2 - Kg (KG) | 2 - Kg (KG)<br /> | ||
4 - Surface (M2) | 4 - Surface (M2)<br /> | ||
5 - Volume (M3) | 5 - Volume (M3) | ||
* The third parameter can be used to give the volume. | * The third parameter can be used to give the volume. | ||
Line 33: | Line 33: | ||
if objTable.Locate("SG_MATNR","RVS306") then | if objTable.Locate("SG_MATNR","RVS306") then | ||
set objCalc = pdc.NewCalculation | set objCalc = pdc.NewCalculation | ||
set objMat = objCalc.MaterialList.AddComposedMaterial("RVS306",4) 'RVS306 added as sheet | set objMat = objCalc.MaterialList.AddComposedMaterial("RVS306",4,0,0) 'RVS306 added as sheet | ||
thickness = 20 'mm | thickness = 20 'mm | ||
objMat.Description = "PLAAT-" & thickness & "MM" | objMat.Description = "PLAAT-" & thickness & "MM" | ||
Line 43: | Line 43: | ||
weigth = 1000 * volume * weigthfac | weigth = 1000 * volume * weigthfac | ||
objMat.PricePerUnit = volume * weigthfac * 1000 * objTable.GetField("SG_PRIJS") | objMat.PricePerUnit = volume * weigthfac * 1000 * objTable.GetField("SG_PRIJS") | ||
objMat.SurfaceFactor = 2 '2 for sheets | 'objMat.SurfaceFactor = 2 '2 for sheets THIS PROPERTY DOES NOT EXIST! | ||
objMat.Weight = weigth | objMat.Weight = weigth | ||
objMat.WeightFact = weigth | objMat.WeightFact = weigth |
Latest revision as of 13:35, 8 March 2016
Declaration
AddComposedMaterial(MaterialKind as String,ComposedMaterialType as Integer, Volume as Double, Surface as Double) as PdcMaterial
Description
Returns an new added composed material object.
Notes
This method add an material to the materiallist.
- The first parameter determines the materialkind.
- The second parameter is composed material type, with the following options:
0 - Piece
1 - Meter (M)
2 - Kg (KG)
4 - Surface (M2)
5 - Volume (M3)
- The third parameter can be used to give the volume.
- The fourth parameter can be used to give the surface.
Code example
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,0,0) '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 THIS PROPERTY DOES NOT EXIST!
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