Dear Sir,
I am using Inventor 2011. I tried to use your code and found "'Let' and 'Set' assignment statements are no longer supported.". So i removed the code, now its asking for "Expression expected." Can you please solve the bug in the code below. Thanks in Advance - Carthik
Public Sub Main()
ins_comp("PinLink ANSI 50.ipt","RollerLink ANSI 50.ipt")
End Sub
Function ins_comp(p1 as String, p2 as String)
' Get the component definition of the currently open assembly.
' This will fail if an assembly document is not open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Create a new matrix object. It will be initialized to an identity matrix.
Dim oMatrix As Matrix
oMatrix = ThisApplication.TransientGeometry.CreateMatrix
oMatrix.SetTranslation(ThisApplication.TransientGeometry.CreateVector(0,0,0))
'file path to use
oPath = ThisDoc.Path & "\"
'file to use
oFile = ins_comp_name
' Place the first occurrence.
Dim oOcc1 As ComponentOccurrence
MessageBox.Show("Message"&p1, "Title")
oOcc1 = oAsmCompDef.Occurrences.Add(& vbLf & oPath & p1, oMatrix)
' Place the second occurrence, but use iMates for its placement. This is
' equivalent to "Use iMate" check box on the "Place Component" dialog.
Dim oOccEnumerator As ComponentOccurrencesEnumerator
oOccEnumerator = oAsmCompDef.Occurrences.AddUsingiMates(& vbLf & oPath & p2, False)
' Since the 'PlaceAllMatching' flag was specified as False, we can be
' sure that just one ComponentOccurrence was returned in the enumerator.
' oOcc1 = oOccEnumerator.Item(1)
End Function