Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Thomas.Long
523 Views, 2 Replies

Multiple classes, object references & Shared subs

I'm having a bit of difficulty with some slightly more elaborate classes that I'm working with. To date I've only done a simple one with 3 or 4 values that I passed directly into the class and that was it. 

 

My first class in this code, however, is supposed to be passed a component occurrence. From there it does a look up inside of the function new and gets a variety of parameters and writes them into the various class parameters for ease of access. One of the things its supposed to do is create an array of a secondary class that contains a lot of geometric information involved in the component. That part of the program also needs to do an excel lookup for various information relevant to that geometric information.

 

Unfortunately I keep getting "Reference to a non-shared member requires an object reference." It does these for all the parameters and the excel lookup. I fixed the parameters by using the component occurrence to reference the component occurrences parameters directly rather than using the assembly parameter function that inventor specifies. However, I see no other way than the FindRow statement in order to do my lookup in excel (excluding the possibility of creating an instance of excel, silently opening the referenced workbook, and doing it manually, something I'm not willing to do quite yet)

 

I've tried making it shared thus far, but Shared does not apparently allow for public statement and will not allow the passing of parameters into the function, so I'm kinda stuck? Any ideas would be most appreciated.

 

Thank you,

Thomas Long

 

Public Class Base

	Public BeamList() As Beam
	Public oLength As Double
	Public oWidth As Double
	Public oHeight As Double
	Public oName As String
	Public oSplits(3) As Boolean
	Public oPart As ComponentOccurrence
	Public oSectionNumber As Integer

	
	Public Sub New(oPart As ComponentOccurrence)
	
		oDoc = oPart.Definition.Document
				
		MyClass.oLength = oDoc.ComponentDefinition.Parameters.Item("SectionLength").Value
		MyClass.oWidth = oDoc.ComponentDefinition.Parameters.Item("SectionWidth").Value
		MyClass.oHeight = oDoc.ComponentDefinition.Parameters.Item("GirderHeight").Value
		MyClass.oName = oPart.Name
		MyClass.oPart = oPart
		'MyClass.oSectionNumber = Split(iProperties.Value("Custom", "ETO Item"), "H00")(UBound(Split(iProperties.Value("Custom", "ETO Item"))))
		
		For Each oVal in MyClass.oSplits
			oVal = False
		Next
		
		If oDoc.ComponentDefinition.Parameters.Item("LengthwiseSplits").Value = "Side A" Or oDoc.ComponentDefinition.Parameters.Item("LengthwiseSplits").Value = "Side A & C" Then MyClass.oSplits(0) = True
		If oDoc.ComponentDefinition.Parameters.Item("WidthwiseSplits").Value = "Side B" Or oDoc.ComponentDefinition.Parameters.Item("WidthwiseSplits").Value = "Side B & D" Then MyClass.oSplits(1) = True
		If oDoc.ComponentDefinition.Parameters.Item("LengthwiseSplits").Value = "Side C" Or oDoc.ComponentDefinition.Parameters.Item("LengthwiseSplits").Value = "Side A & C" Then MyClass.oSplits(2) = True
		If oDoc.ComponentDefinition.Parameters.Item("WidthwiseSplits").Value = "Side D" Or oDoc.ComponentDefinition.Parameters.Item("WidthwiseSplits").Value = "Side B & D" Then MyClass.oSplits(3) = True

		ReDim MyClass.BeamList(oDoc.ComponentDefinition.Parameters.Item("Beams").Value-1)
		
		For i = 0 To UBound(MyClass.BeamList)
			MyClass.BeamList(i) = New Beam(oDoc.ComponentDefinition.Parameters.Item("Beam_" & i+1).Value, oDoc.ComponentDefinition.Parameters.Item("Location_" & i+1).Value, oDoc.ComponentDefinition.Parameters.Item("Facing_" & i+1).Value)
		Next
	End Sub
End Class
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\




'Defines an instance of a beam
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Public Class Beam

	Public oSize As String
	Public oLocation As Double
	Public oFacing As String
	Public oFlangeWidth As Double
	Public oMidPoint As Double
	
	Public Sub New(oSize As String, oLocation As Double, oFacing As String)
	
		MyClass.oSize = oSize
		MyClass.oLocation = oLocation
		MyClass.oFacing = oFacing
		
		GoExcel.FindRow("N:\Mechpart\TLONG\Reference Materials\Information\BEAM INFORMATION.xlsx", "Channels", "Beam Size", "=", oSize)
		MyClass.oFlangeWidth = GoExcel.CurrentRowValue("FlangeWidth")
		
		If oFacing = "Right"
			MyClass.oMidPoint = oLocation + .5*GoExcel.CurrentRowValue("FlangeWidth")
		ElseIf oFacing = "Left"
			MyClass.oMidPoint = oLocation - .5*GoExcel.CurrentRowValue("FlangeWidth")
		End If
	End Sub
End Class
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\