I LOGIC code question

I LOGIC code question

corey_danielson
Advocate Advocate
963 Views
11 Replies
Message 1 of 12

I LOGIC code question

corey_danielson
Advocate
Advocate

I will explain this the best I can.

 

I am setting up some standard bolts, I would like to create a form where someone could select bolt size, (3/4-10)

Length (2,2 1/4, etc) and grade (Grade 5 or 8) This way they would not have the scroll through all the options when I have the one column with all the information.  This is part of what I have for now, this includes all bolt options 1/4 - 1"


If DescriptionBolt = "HEX BOLT 3/4-10 X 2 1/2 GR.5" Then
LENGTH = 2.5
THREADLENGTH = .75
SLOTPATTERN = 3
HEADTHICKNESS = .46875
DIAMETER = .75
HEX = 1.125
boltpartnumber = "HB-NC.75-10X2.5 GR5"
Feature.IsActive("Thread3") = True
Feature.ThreadDesignation("Thread3") = "3/4-10 UNC"
End If

If DescriptionBolt = "HEX BOLT 3/4-16 X 2 1/2 GR.5" Then
LENGTH = 2.5
THREADLENGTH = .75
SLOTPATTERN = 3
HEADTHICKNESS = .46875
DIAMETER = .75
HEX = 1.125
boltpartnumber = "HB-NC.75-16X2.5 GR5"
Feature.IsActive("Thread3") = True
Feature.ThreadDesignation("Thread3") = "3/4-16 UNF"
End If

 

 

Can do something like:

 

If DescriptionBolt = "HEX BOLT 3/4-10  and Length = Length and grade = grade then

BOLTDESCRIPTION = HEXBOLT 3/4-10 X "LENGTH" X "GRADE"

 

If I selected 3/4-10,  2 1/2, and Grade 5

 

 I would like the description to look like this - HEX HEAD BOLT 3/4-10 X 2 1/2 GR5

 

I would have 3 multi line parameters named DescriptionBolt, Length. and Grade

 

I need some help on setting this up to work. Did I explain this ok?

 

Thank you

 

 

0 Likes
Accepted solutions (3)
964 Views
11 Replies
Replies (11)
Message 2 of 12

corey_danielson
Advocate
Advocate

this may explain better what I am trying to do

0 Likes
Message 3 of 12

Curtis_Waguespack
Consultant
Consultant

@corey_danielson , post your part file ( and mention what version of Inventor you are using) and I'm sure someone will take a look. As it is, I don't think there is not enough information to assist.

EESignature

0 Likes
Message 4 of 12

corey_danielson
Advocate
Advocate

Inventor Professional 2022.1.1

 

This is the part I am trying to have a form

 You can see the forms I have in here. Form 2 is the one I would like to work as is. (Pick your bolt was the original try)

Does this help? Let me know what else you need. Thank you.

Message 5 of 12

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@corey_danielson , see this example. I feel like there is a more straight forward way to convert the fractional string into a decimal, but it didn't come to mind... maybe someone else will think of it.

In any case, this example works by splitting the fraction into a parts.

Hope that helps,

Curtis

 

If Parameter("BOLT_DESCRIPTION") = BOLT_DESCRIPTION Then
	iProperties.Value("Project", "Description") = BOLT_DESCRIPTION
	iProperties.Value("Project", "Part Number") = boltpartnumber
End If

If Parameter("GRADE") = GR5 Then
	SLOTPATTERN = 3
ElseIf Parameter("GRADE") = GR8 Then
	SLOTPATTERN = 5
End If

If DescriptionBolt = "HEX BOLT 1/4-20" Then

	oLength = BOLT_LENGTH
	If oLength.Contains("/") Then 'if the value has a forward slash, then convert to decimal
		'example: 3 1/4
		sArray = Split(BOLT_LENGTH, " ") 'split the string into parts using the space as the seperator	
		Dim Int As Integer = sArray(0) 'example returns: 3
		Dim Fraction As String = sArray(1) 'example returns: 1/4
		sFractionArray = Split(Fraction, "/") 'split the remainer into parts using the / as the seperator
		'example returns: 1 and 4
		'	sFractionArray(0) , would be 1
		' 	sFractionArray(1)  , would be 4
		Dim Dbl As Double = sFractionArray(0) / sFractionArray(1) 'example returns 0.25
		oLength = Int + Dbl ' assembly the decimal, example returns 3.25
	End If
	
	LENGTH = oLength

	THREADLENGTH = .75
	SLOTPATTERN = SLOTPATTERN
	HEADTHICKNESS = .15625
	DIAMETER = .25
	HEX = .4375
	boltpartnumber = (DescriptionBolt) & "X" & (BOLT_LENGTH) & (GRADE)
	BOLT_DESCRIPTION = DescriptionBolt & " X " & BOLT_LENGTH & " " & GRADE
	Feature.IsActive("Thread3") = True
	Feature.ThreadDesignation("Thread3") = "1/4-20 UNC"
End If



iLogicVb.UpdateWhenDone = True



 

EESignature

0 Likes
Message 6 of 12

corey_danielson
Advocate
Advocate

Thank you VERY much, I can work with this. I cannot get it to switch between grade 5 and grade 8 now, but the length is working perfectly!

Message 7 of 12

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@corey_danielson , ahh I didn't look at grade before, but you can just move the iProps block down to the bottom as shown and remove the if/then as shown

 

If Parameter("GRADE") = GR5 Then
	SLOTPATTERN = 3
ElseIf Parameter("GRADE") = GR8 Then
	SLOTPATTERN = 5
End If

If DescriptionBolt = "HEX BOLT 1/4-20" Then

	oLength = BOLT_LENGTH
	If oLength.Contains("/") Then 'if the value has a forward slash, then convert to decimal
		'example: 3 1/4
		sArray = Split(BOLT_LENGTH, " ") 'split the string into parts using the space as the seperator	
		Dim Int As Integer = sArray(0) 'example returns: 3
		Dim Fraction As String = sArray(1) 'example returns: 1/4
		sFractionArray = Split(Fraction, "/") 'split the remainer into parts using the / as the seperator
		'example returns: 1 and 4
		'	sFractionArray(0) , would be 1
		' 	sFractionArray(1)  , would be 4
		Dim Dbl As Double = sFractionArray(0) / sFractionArray(1) 'example returns 0.25
		oLength = Int + Dbl ' assembly the decimal, example returns 3.25
	End If

	LENGTH = oLength

	THREADLENGTH = .75
	SLOTPATTERN = SLOTPATTERN
	HEADTHICKNESS = .15625
	DIAMETER = .25
	HEX = .4375
	boltpartnumber = (DescriptionBolt) & "X" & (BOLT_LENGTH) & (GRADE)
	BOLT_DESCRIPTION = DescriptionBolt & " X " & BOLT_LENGTH & " " & GRADE
	Feature.IsActive("Thread3") = True
	Feature.ThreadDesignation("Thread3") = "1/4-20 UNC"
End If

iProperties.Value("Project", "Description") = BOLT_DESCRIPTION
iProperties.Value("Project", "Part Number") = boltpartnumber


iLogicVb.UpdateWhenDone = True


 

EESignature

0 Likes
Message 8 of 12

corey_danielson
Advocate
Advocate

Any idea how to make the grade work? It was working earlier. I will keep looking at it as well. Can't tell you how much I appreciate your help. Thank you

0 Likes
Message 9 of 12

Curtis_Waguespack
Consultant
Consultant
Accepted solution

The last example should fix the grade as far as updating the part number and description. Was there more to what Grade should do than updating those?

EESignature

0 Likes
Message 10 of 12

corey_danielson
Advocate
Advocate

Curtis,

 

I just checked, the part number and description are updating correctly, my slot pattern isn't changing from 3 to 5. 

0 Likes
Message 11 of 12

corey_danielson
Advocate
Advocate
I was originally going to have a part for each size bolt, this was how it was working. d13 was the slot pattern quantity

If
Parameter("DescriptionBolt") = DescriptionBolt Then iProperties.Value("Project", "Description") = DescriptionBolt iProperties.Value("Project", "Part Number") = boltpartnumber Parameter("HEADTHICKNESS") = .390625 Parameter("DIAMETER") = .625 Parameter("HEX") = .9375 End If If DescriptionBolt = "HEX BOLT <material> 5/8-11 X 2 1/2 GR.5" Then LENGTH = 2.5 THREADLENGTH = 1.25 d13 = 3 boltpartnumber = "HB-NC.625-11X2.5GR5" Feature.IsActive("Thread3") = True Feature.ThreadDesignation("Thread3") = "5/8-11 UNC" End If If DescriptionBolt = "HEX BOLT 5/8-11 X 2 1/2 GR.8" Then LENGTH = 2.5 THREADLENGTH = 1.25 d13 = 5 boltpartnumber = "HB-NC.625-11X2.5GR5" Feature.IsActive("Thread3") = True Feature.ThreadDesignation("Thread3") = "5/8-11 UNC" End If If DescriptionBolt = "HEX BOLT 5/8-18 X 2 1/2 GR.5" Then LENGTH = 2.5 THREADLENGTH = 1.25 d13 = 3 boltpartnumber = "HB-NF.625-18X2.5GR5" Feature.IsActive("Thread3") = True Feature.ThreadDesignation("Thread3") = "5/8-18 UNF"

 

0 Likes
Message 12 of 12

corey_danielson
Advocate
Advocate

Curtis,  I got it! it all works now. Slots change when i change the grade in my form