- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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")
Or if this helped you, please, click (like)
Regards
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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")
Or if this helped you, please, click (like)
Regards
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
NOW IM GETTING THIS:
Error on Line 112 : 'SALES_ORDER_' is not declared. It may be inaccessible due to its protection level.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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("-")
Or if this helped you, please, click (like)
Regards
Alan