- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Applying Cost To A Material
Hi,
I was wondering is it possible to add a cost to a material, i know of the other solutions were you add cost to the iProperties of a part, this is not what i want. Im talking in terms of adding a cost to a finish, for example. If i want a powder coat finish, i would apply a cost to the material finish "powder coat" and then when i applied it to the product, it would give me an overall cost of using the finish "powder coat". Allowing me to know how much it would cost to use different finishes on the product.
Ive been made aware that this can only really be done via Ilogic, however i lack the experience to write something this complex. Could someone point me inn the right direction? I know i will have to first find the mass and then appearance or the part, from there use the cost of the finish and multiple by the overall mass?
Many thanks,
Re: Applying Cost To A Material - Autodesk Community - Inventor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I don't know a way to add cost to a material. Instead, you can save the data in an iLogic rule (or a separate file but that is not in this example). just add the material and cost to the top of the rule.
Public Class ThisRule Sub Main() Dim costs As New Dictionary(Of String, materialCost) ' Add material and csot here. ' costs.Add("[Material name]", New materialCost([Material cost (../Kg)], [Surface treatment cost (../Cm^2)])) costs.Add("Generic", New materialCost(10, 30)) costs.Add("Brass, Soft Yellow", New materialCost(20, 0)) Dim doc As PartDocument = ThisDoc.Document Dim materialName = doc.ActiveMaterial.DisplayName If (costs.ContainsKey(materialName)) Then ' mass is in Kg Dim mass = doc.ComponentDefinition.MassProperties.Mass ' area is in Cm^2 Dim area = doc.ComponentDefinition.MassProperties.Area Dim cost As materialCost = costs.Item(materialName) Dim materialCost = mass * cost.Material Dim surfaceTreatmentCost = area * cost.SurfaceTreatment Dim totalCost = materialCost + surfaceTreatmentCost Dim txt = "Material: " & materialCost & System.Environment.NewLine txt = txt + "Surface treatment: " & surfaceTreatmentCost & System.Environment.NewLine txt = txt + "Total: " & totalCost MsgBox(txt) Else MsgBox("Unable to calculate cost for material: " & materialName) End If End Sub End Class Public Class materialCost Public Sub New(material As Double, surfaceTreatment As Double) Me.Material = material Me.SurfaceTreatment = surfaceTreatment End Sub Public Property Material As Double Public Property SurfaceTreatment As Double End Class
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report