Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am setting up a class that will:
- hold the component occurrence
- get the name of the comp occ
- define a position quadrant from the matrix of the comp occ
- define the direction the part is facing from the matrix of the comp occ
I can pass a component occurrence to the class via "Public Sub New" however I cannot pass that occurrence to a variable which can be read to make the above list. Is a component occurrence an unacceptable data type to be handled by a class?
Public Sub IntGussetsEconToStack()
'get inventor session
Dim InvApp As Inv.Application = SysInter.Marshal.GetActiveObject("Inventor.Application")
Dim InvDoc As Inv.AssemblyDocument = InvApp.ActiveDocument
'===================================================
#Region "get the Interior Stiff occurances"
Console.Write(vbNewLine & vbNewLine)
'Dim ExistingIntFBGussList As New List(Of Inv.ComponentOccurrence)
Dim ExistingIntFBGussList As New List(Of Gusset)
Dim ExistingIntLRGussList As New List(Of Inv.ComponentOccurrence)
For Each OccItem As Inv.ComponentOccurrence In InvDoc.ComponentDefinition.Occurrences
If OccItem.Name.Contains("GUSSET,INT,F&B") Then
Dim Gusset As New Gusset(OccItem)
ExistingIntFBGussList.Add(Gusset)
End If
Next
Console.WriteLine("Existing F/B gussets: " & ExistingIntFBGussList.Count & vbNewLine & "Existing L/R gussets: " & ExistingIntLRGussList.Count & vbNewLine & vbNewLine)
#End Region
End Sub
'===================================================
#Region "Gusset Class"
Public Class Gusset
Protected InvApp As Inv.Application = SysInter.Marshal.GetActiveObject("Inventor.Application")
Protected InvDoc As Inv.AssemblyDocument = InvApp.ActiveDocument
Protected TransGeo As Inv.TransientGeometry = InvApp.TransientGeometry
Protected _Occ As Inv.ComponentOccurrence
Protected GussTrans As Inv.Vector = _Occ.Transformation.Translation
Protected UoM As Inv.UnitsOfMeasure = InvDoc.UnitsOfMeasure
Protected _Name As String = _Occ.Name
'Protected _Location As Inv.Point = TransGeo.CreatePoint(UoM.ConvertUnits(GussTrans.X, Inv.UnitsTypeEnum.kCentimeterLengthUnits, Inv.UnitsTypeEnum.kInchLengthUnits), UoM.ConvertUnits(GussTrans.Y, Inv.UnitsTypeEnum.kCentimeterLengthUnits, Inv.UnitsTypeEnum.kInchLengthUnits), UoM.ConvertUnits(GussTrans.Z, Inv.UnitsTypeEnum.kCentimeterLengthUnits, Inv.UnitsTypeEnum.kInchLengthUnits))
Protected _Quadrant As Quad
Protected _Direction As Direction
Public Sub New(CompOcc As Inv.ComponentOccurrence)
_Occ = CompOcc
End Sub
Public Enum Quad
FR
RR
FL
RL
End Enum
Private Sub AssignQuad()
Select Case True
Case _Location.X >= 0 AndAlso _Location.Z > 0
_Quadrant = Quad.FL
Case _Location.X >= 0 AndAlso _Location.Z < 0
_Quadrant = Quad.RR
Case _Location.X < 0 AndAlso _Location.Z > 0
_Quadrant = Quad.FR
Case _Location.X < 0 AndAlso _Location.Z < 0
_Quadrant = Quad.RL
End Select
End Sub
Public ReadOnly Property Name As String
Get
Return _Name
End Get
End Property
Public ReadOnly Property Location As Inv.Point
Get
Return _Location
End Get
End Property
Public ReadOnly Property Quadrant As String
Get
Return _Quadrant
End Get
End Property
Public Enum Direction
FRONT
BACK
LEFT
RIGHT
End Enum
Private Sub AssignDirection()
Select Case True
Case GussTrans.Cell(1, 4) > 0 AndAlso GussTrans.Cell(3, 4) > 0
_Direction = Direction.BACK
Case GussTrans.Cell(1, 4) > 0 AndAlso GussTrans.Cell(3, 4) < 0
_Direction = Direction.FRONT
Case GussTrans.Cell(1, 4) < 0 AndAlso GussTrans.Cell(3, 4) > 0
_Direction = Direction.BACK
Case GussTrans.Cell(1, 4) < 0 AndAlso GussTrans.Cell(3, 4) < 0
_Direction = Direction.FRONT
End Select
End Sub
End Class
#End Region
Solved! Go to Solution.