Results 1 to 7 of 7

Thread: Visual Basic for Inventor 2016

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2019
    Posts
    3

    Visual Basic for Inventor 2016

    I am totally new to these forums and almost as new to trying to code as well. So if I am in the wrong spot just let me know where to go, it wasn't intentional.

    What I am trying to do is this:

    I have a part number (.ipt) file with the file name 9999-ABCDEF. I used the following code to isolate each extension and place them in an array. I've also defined the values that each of the extension letters tie to, and have placed their variants into arrays as well. For example, the first extension is the letter "A". This extension is tied to the LengthVariants array which should drive the part length to be 12". If the second extension is "B" which (being tied to the HeightVariants array) should drive the part height should be 3".

    My plan was to have each letter of the extension convert to a number that I then use as my reference point for pulling the dimension value from the secondary arrays. ("A" would convert to 0 and the code would search LengthVariants(0) to get 12".

    However I cannot figure out the way to convert the letter codes from my first array into numbers that I can use as index points for my secondary arrays. How can I replace characters with numbers in an array?

    Code:
    'FileName
    Name=ThisDoc.FileName(False)
    
    'Dividing Symbol
    Delimiter = InStr (Name,"-")
    
    'The Count of Extensions past the Delimiter
    ExtensionLength = Len(Name)-Delimiter
    
    'Setting Array That Holds The Characters of all the extensions
    Dim Extensions(ExtensionLength-1) As String
    
    'The Next Count/While Loop Sets the Specific Values in the array based off the extension E(0) will be the first extension, E(1) the second, etc.
    'TEST KEY'
    'Extensions(0)=LengthVariants Extension Letter
    'Extensions(1)=HeightVariants Extension Letter
    'Extensions(2)=FlangeVariants Extension Letter
    'Extensions(3)=FirstCutoutVariants Extension Letter
    'Extensions(4)=StrandCentersVariants Extension Letter
    'Extensions(5)=StrandQTYVariants Extension Letter
    Count = 0
    While Count < ExtensionLength
    Extensions(Count)=Left(Right(Name,Len(Name)-Delimiter-Count),1)
    Count = Count + 1
    End While
    'End of loop to seperate and assign each extension
    
    'Setting Array That Holds all the possible values of each extension
    LengthVariants = New Double(){12,24,36,48,60,72,84,96,108,120}
    HeightVariants = New Double(){2,3,4,5,6,6.5,7,8,9,10}
    FlangeVariants = New Double(){1,1.5,2,2.5,3}
    FirstCutoutVariants = New Double(){6,9,12,15,18,21,24,27,30}
    StrandCentersVariants = New Double(){6,9,12,15,18,21,24,27,30}
    StrandQTY = New Double(){1,2,3,4,5,6}
    
    'Setting Array to Convert Letter Code into index reference point for above arrays
    '(Cant Figure this part out)
    Last edited by TheMechEngineer; Oct 17th, 2019 at 04:42 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width