- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone I'm trying to import an .obj into an assembly using vb.net. I need to change its units from the default it comes in as inches and I want it to be meters.
This is the code I have so far.
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
Dim inventor = _invApp.Documents 'access the inventor document subclass
inventor.Open("D:\Project Files\Inventor\CAD Files\assembly.iam", True)
'Get application information.
Dim assembly_doc As AssemblyDocument ' get the active part document
assembly_doc = _invApp.ActiveDocument 'set part_doc as the active part document
Dim assembly_component As AssemblyComponentDefinition 'set the assembly component definition.
assembly_component = assembly_doc.ComponentDefinition
Dim trans_geo As TransientGeometry 'get transient geometry from the application
trans_geo = _invApp.TransientGeometry 'set trans_geo as Transient Geometry object
'define part file names
Dim part1_str As String = "D:\Project Files\Test Files\part1.obj"
'Now that the assembly file is open and active add the part
'first we need to make a position and orientation matrix and file name to be used when its added to the assembly.
Dim left_matrix As Matrix = trans_geo.CreateMatrix 'Create a matrix for positioning the foot.
Call left_matrix.SetToRotation(0, trans_geo.CreateVector(0, 0, 1), trans_geo.CreatePoint(0, 0, 0)) 'set the matrices rotation component.
Call left_matrix.SetTranslation(trans_geo.CreateVector(-0.3, 0, 0), True) 'set the matrices translation component.
'Open the part
Dim comp_occurence As Inventor.ComponentOccurrence 'Define the component occurence.
comp_occurence = assembly_doc.ComponentDefinition.Occurrences.Add(part1_str, left_matrix)
End Sub
Solved! Go to Solution.