<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Placing and rotating parts around multiple axis in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/placing-and-rotating-parts-around-multiple-axis/m-p/6788414#M69130</link>
    <description>&lt;P&gt;I have a function that is meant to place a part, rotate and move it to its proper placement, then ground it there. However, I'm having a bit of an issue with my rotation portion of the function. It appears that its either flipping it 180 degrees or doing nothing at all in all three directions. If I try to rotate it three different times however, it just uses the final rotation and ignores the other 2. How do I get it to rotate different angles for all 3 axis?&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;'Places, rotates and grounds component
'//////////////////////////////////////////////////
Public Function PlaceComponent(Part As String, X As Double, Y As Double, Z As Double, XYRotation As Double, XZRotation As Double, YZRotation As Double)

	'Select component to be placed
	'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
	InventorVb.RunMacro("ApplicationProject","Place_Part","Place_Part", Part)
	'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
	
	Dim FileNameArray() As String = Part.Split("\")
	Dim PartName() As String = FileNameArray(UBound(FileNameArray)).Split(".")
	
	'Set Active Assembly
	Dim oAsmDoc As AssemblyDocument
	oAsmDoc = ThisApplication.ActiveDocument
	
	'Assembly definition 
	Dim oAsmDef As AssemblyComponentDefinition
	oAsmDef = oAsmDoc.ComponentDefinition
	
	'Component definition
	Dim oOcc As ComponentOccurrence 
	
	'Get all leaf occurrences of the assembly
	Dim oLeafOccs As ComponentOccurrencesEnumerator
	oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences
	
	'Latest occurrrence holder
	Dim MaxValue
	MaxValue = 0
	
	'Name of Latest Occurrence
	Dim Name As String
	Name = ""
	
	'Iterate through all Of the occurrence In this collection, finds the latest occurrence, And sets it To reference
	Dim Instances As New ArrayList

	For Each oOcc In oLeafOccs
		Dim oOccPart() As String = oOcc.Name.Split(":")
		If oOccPart(0) = PartName(0) Then Instances.add(oOcc.Name)
	Next

	For Each oval in Instances
		Dim InstanceNumber() As String = oOcc.Name.Split(":")
		If InstanceNumber(1) &amp;gt; MaxValue Then Name = oval	
	Next
	
	For Each oOcc In oLeafOccs
		If oOcc.Name = Name
			oOcc.Grounded = False
			
			Dim uom As UnitsOfMeasure = ThisDoc.Document.UnitsOfMeasure
			Dim convFactor As Double = uom.ConvertUnits(1.0, uom.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits)
			
			' Get the current transformation matrix from the occurrence.
			Dim oTransform As Matrix = oOcc.Transformation
			Dim oTG As TransientGeometry
			
			oTG = ThisApplication.TransientGeometry
			
			XYRotationRadian = XYRotation*PI/180
			XZRotationRadian = XZRotation*PI/180
			YZRotationRadian = YZRotation*PI/180
			
	
			' Move the occurrence ignoring any constraints.
			oTransform.SetToRotation(PI, oTG.CreateVector(XYRotationRadian, XZRotationRadian, YZRotationRadian), oTG.CreatePoint(X / 10, Y / 10, Z / 10)) 
			oTransform.SetTranslation(ThisApplication.TransientGeometry.CreateVector(X*convFactor, Y*convFactor, Z*convFactor))
			oOcc.SetTransformWithoutConstraints(oTransform)
			
			' ground the component
			oOcc.Grounded = True
		End If
	Next	
End Function&lt;/PRE&gt;</description>
    <pubDate>Fri, 06 Jan 2017 18:47:02 GMT</pubDate>
    <dc:creator>Thomas.Long</dc:creator>
    <dc:date>2017-01-06T18:47:02Z</dc:date>
    <item>
      <title>Placing and rotating parts around multiple axis</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/placing-and-rotating-parts-around-multiple-axis/m-p/6788414#M69130</link>
      <description>&lt;P&gt;I have a function that is meant to place a part, rotate and move it to its proper placement, then ground it there. However, I'm having a bit of an issue with my rotation portion of the function. It appears that its either flipping it 180 degrees or doing nothing at all in all three directions. If I try to rotate it three different times however, it just uses the final rotation and ignores the other 2. How do I get it to rotate different angles for all 3 axis?&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;'Places, rotates and grounds component
'//////////////////////////////////////////////////
Public Function PlaceComponent(Part As String, X As Double, Y As Double, Z As Double, XYRotation As Double, XZRotation As Double, YZRotation As Double)

	'Select component to be placed
	'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
	InventorVb.RunMacro("ApplicationProject","Place_Part","Place_Part", Part)
	'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
	
	Dim FileNameArray() As String = Part.Split("\")
	Dim PartName() As String = FileNameArray(UBound(FileNameArray)).Split(".")
	
	'Set Active Assembly
	Dim oAsmDoc As AssemblyDocument
	oAsmDoc = ThisApplication.ActiveDocument
	
	'Assembly definition 
	Dim oAsmDef As AssemblyComponentDefinition
	oAsmDef = oAsmDoc.ComponentDefinition
	
	'Component definition
	Dim oOcc As ComponentOccurrence 
	
	'Get all leaf occurrences of the assembly
	Dim oLeafOccs As ComponentOccurrencesEnumerator
	oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences
	
	'Latest occurrrence holder
	Dim MaxValue
	MaxValue = 0
	
	'Name of Latest Occurrence
	Dim Name As String
	Name = ""
	
	'Iterate through all Of the occurrence In this collection, finds the latest occurrence, And sets it To reference
	Dim Instances As New ArrayList

	For Each oOcc In oLeafOccs
		Dim oOccPart() As String = oOcc.Name.Split(":")
		If oOccPart(0) = PartName(0) Then Instances.add(oOcc.Name)
	Next

	For Each oval in Instances
		Dim InstanceNumber() As String = oOcc.Name.Split(":")
		If InstanceNumber(1) &amp;gt; MaxValue Then Name = oval	
	Next
	
	For Each oOcc In oLeafOccs
		If oOcc.Name = Name
			oOcc.Grounded = False
			
			Dim uom As UnitsOfMeasure = ThisDoc.Document.UnitsOfMeasure
			Dim convFactor As Double = uom.ConvertUnits(1.0, uom.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits)
			
			' Get the current transformation matrix from the occurrence.
			Dim oTransform As Matrix = oOcc.Transformation
			Dim oTG As TransientGeometry
			
			oTG = ThisApplication.TransientGeometry
			
			XYRotationRadian = XYRotation*PI/180
			XZRotationRadian = XZRotation*PI/180
			YZRotationRadian = YZRotation*PI/180
			
	
			' Move the occurrence ignoring any constraints.
			oTransform.SetToRotation(PI, oTG.CreateVector(XYRotationRadian, XZRotationRadian, YZRotationRadian), oTG.CreatePoint(X / 10, Y / 10, Z / 10)) 
			oTransform.SetTranslation(ThisApplication.TransientGeometry.CreateVector(X*convFactor, Y*convFactor, Z*convFactor))
			oOcc.SetTransformWithoutConstraints(oTransform)
			
			' ground the component
			oOcc.Grounded = True
		End If
	Next	
End Function&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Jan 2017 18:47:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/placing-and-rotating-parts-around-multiple-axis/m-p/6788414#M69130</guid>
      <dc:creator>Thomas.Long</dc:creator>
      <dc:date>2017-01-06T18:47:02Z</dc:date>
    </item>
  </channel>
</rss>

