Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, I'm using ilogic to create an assembly, but I need to change the material of the components. I'm trying to change it when defining the component's operations, but it just doesn't seem to work. I'm trying to use the method:
iProperties.Material = "Copper"
But it just won't work.
The following is a part of my code where I make a part and try to change its material before placing it in the assembly:
Public Sub Main() '/ Assembly Definitions / Dim BaugDok As AssemblyDocument Dim BaugDef As AssemblyComponentDefinition Dim BautDok As PartDocument Dim BautDef As PartComponentDefinition Dim Martrix As Matrix Dim Occ As ComponentOccurrence check = False BaugDok = ThisApplication.ActiveDocument BaugDef = BaugDok.ComponentDefinition '/ Call the function that creates the part / BautDok = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject,ThisApplication.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject,SystemOfMeasureEnum.kDefaultSystemOfMeasure,DraftingStandardEnum.kDefault_DraftingStandard,"{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}")) BautDef = BautDok.ComponentDefinition Call LBW() '/ Give a 45 gegrees orientation / Martrix = ThisApplication.TransientGeometry.CreateMatrix() Martrix.SetToRotation(3.14159265358979 / 4, _ ThisApplication.TransientGeometry.CreateVector(0, 0, 0), ThisApplication.TransientGeometry.CreatePoint(0, 0, 0)) '/ Place component in origin / Martrix.SetTranslation(ThisApplication.TransientGeometry.CreateVector(0, 0, 0)) Occ = BaugDef.Occurrences.AddByComponentDefinition(BautDef, Martrix) End Sub '/ Functions to create part / Sub LBW() Dim partDoc As PartDocument Dim iApp As Inventor.Application Dim partDef As PartComponentDefinition Dim sketch1 As Sketch Dim sk As Sketch Dim tg As Inventor.TransientGeometry Dim SWCurve As SketchArc partDoc = ThisApplication.ActiveDocument partDef = partDoc.ComponentDefinition iApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") tg = iApp.TransientGeometry Call LBWPROF(sketch1, tg, partDef, sk) iProperties.Material = "Copper" End Sub Public Function LBWPROF(sketch1, tg, partDef, sk) As Double Dim Path As Path Dim PF As Profile Dim SWP As SweepFeature sketch1 = partDef.Sketches.Add(partDef.WorkPlanes.Item(3)) sketch1.SketchCircles.AddByCenterRadius(tg.CreatePoint2d(0, 0), 0.47625) sketch1.SketchCircles.AddByCenterRadius(tg.CreatePoint2d(0, 0), .42035) sk = partDef.Sketches.Add(partDef.WorkPlanes.Item(2)) sk.SketchArcs.AddByCenterStartEndPoint(tg.CreatePoint2d(-2.54/2,0), tg.CreatePoint2d(0,0), tg.CreatePoint2d(-2.54,0),False) SWCurve = partDef.Sketches.Item(2).SketchArcs.Item(1) Path = partDef.Features.CreatePath(SWCurve) PF = partDef.Sketches.Item(1).Profiles.AddForSolid(True) SWP = partDef.Features.SweepFeatures.AddUsingPath(PF, Path, kJoinOperation) End Function
Thanks in advance.
Solved! Go to Solution.