part numbers

part numbers

Lupe_Stewart
Advocate Advocate
775 Views
5 Replies
Message 1 of 6

part numbers

Lupe_Stewart
Advocate
Advocate

I have a part number 123456-01-01 - i want to only have the 123456 as a separate parameter, how do i do that?? with out having to enter the number in two separate fields

0 Likes
Accepted solutions (1)
776 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

There was a post recently where I used Split for solid body names https://forums.autodesk.com/t5/inventor-forum/adding-prefix-to-body-name/m-p/10431354#M832600. Works very well for this situation.

 

The below splits the part number using the special character "-" as a reference to where to stop counting. The string is then directly linked to Project Text parameter or wherever you like. 

Dim PartNo As String
PartNo = iProperties.Value("Project", "Part Number")
'Creats an array of strings seperated by "-"
myparams = PartNo.Split("-")
replaceString1 = myparams(0)'123456
replaceString2 = myparams(1)'01
replaceString3 = myparams(2)'01

MessageBox.Show(replaceString1, "Title")
MessageBox.Show(replaceString2, "Title")
MessageBox.Show(replaceString3, "Title")

Dim Name As String
'Place the Name into a parameter or use it in some way. 

'You can use input box to select which string you want to use, or in this case just to show the array contents
'Name = InputListBox("Prompt", myparams, d0, Title := "Title", ListName := "List")

'By pass selection box and use direct link
Name = replaceString1
'Create text parameter called "Project" first manually
Project = Name
MessageBox.Show(Name , "Title")

 

Here is another where the array of strings are fed into an input box and you can pick what to use .

Dim PartNo As String
PartNo = iProperties.Value("Project", "Part Number")
'Creats an array of strings seperated by "-"
myparams = PartNo.Split("-")
replaceString1 = myparams(0)'123456
replaceString2 = myparams(1)'01
replaceString3 = myparams(2)'01

MessageBox.Show(replaceString1, "Title")
MessageBox.Show(replaceString2, "Title")
MessageBox.Show(replaceString3, "Title")

Dim Name As String
'Place the Name into a parameter or use it in some way. 

'You can use input box to select which string you want to use, or in this case just to show the array contents
Name = InputListBox("Prompt", myparams, Name, Title := "Title", ListName := "List")

'Create text parameter called "Project" first manually
Project = Name
MessageBox.Show(Name, "Title")

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

Lupe_Stewart
Advocate
Advocate

THANKS FOR THE REPLY.... THIS IS WHAT I HAVE...... NOT SURE IF I AM DOING THIS CORRECTLY... BUT THIS IS THE WAY THE NUMBERING SYSTEM GOES:

Dim SALE_ORDER_ As String
SALE_ORDER_ = iProperties.Value("Project", "Part Number")
myparams = Part Number.Split("-")
SALE_ORDER_ = myparams(0)'123456
UNIT NUMBER = myparams(1)'01
PART NUMBER = myparams(2)'01

MessageBox.Show(replaceString1, "Title")
MessageBox.Show(replaceString2, "Title")
MessageBox.Show(replaceString3, "Title")
0 Likes
Message 4 of 6

A.Acheson
Mentor
Mentor

There was some spaces in the Names you were using  "UNIT NUMBER"   "PART NUMBER"  just like parameter names you cannot have spaces.  

 

Also

myparams = Part Number.Split("-")

Should Be

myparams = SALE_ORDER_.Split("-")

 

Working:

Dim SALE_ORDER_ As String
SALE_ORDER_ = iProperties.Value("Project", "Part Number")
myparams = SALE_ORDER_.Split("-")
SALE_ORDER_ = myparams(0)'123456
UNIT_NUMBER = myparams(1)'01
PART_NUMBER = myparams(2)'01

MessageBox.Show(SALE_ORDER_, "Title")
MessageBox.Show(UNIT_NUMBER, "Title")
MessageBox.Show(PART_NUMBER, "Title")

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 6

Lupe_Stewart
Advocate
Advocate

NOW IM GETTING THIS:

Error on Line 112 : 'SALES_ORDER_' is not declared. It may be inaccessible due to its protection level.

0 Likes
Message 6 of 6

A.Acheson
Mentor
Mentor
Accepted solution

Does it work with just the message box or are you using it elsewhere? It seemed to work for me the first time. Not at the computer now but maybe change the first part back to this.  Keep the original string separate than the new. 

Dim PartNo As String
PartNo = iProperties.Value("Project", "Part Number")
'Creates an array of strings seperated by "-"
myparams = PartNo.Split("-")

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes