- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to write an iLogic rule using some calculations that will derive values to be used in multiple Rectangular Patterns in a part. Rather than re-write the math calculations for each pattern, I would like to write a sub routine or loop that would derive the values that could then be applied to the various parameters throughout the part. The math that would be repeated in a subroutine is as follows:
patternWidth = width - leftOffset - rightOffset 'Calculates number of horizontal holes iteration = patternWidth / 90 inc = 1 'rounding increment roundedIteration = Floor(Round(iteration, 4) / inc) * inc 'Check rounded number 'MsgBox(roundedIteration) iterationNumber = (roundedIteration - 1) 'Pattern Iteration Number of Holes 'Calculates distance between pattern holes patternSpace = patternWidth / roundedIteration inc = 1 'rounding increment roundedSpace = Ceil(Round(patternSpace, 4) / inc) * inc 'Check rounded number 'MsgBox(roundedSpace) patternWidthCenter = patternWidth / 2 + leftOffset top_patternWidthCenter_odd = patternWidthCenter + (roundedSpace / 2) bottom_patternWidthCenter_odd = patternWidthCenter - (roundedSpace / 2)
The values derived from above would then be used in a Select Case that sets the various configurations of the part (in this case, the number of folds in a back).
Select Case foldNumber Case 0 d9=leftOffset d10=rightOffset d32=iterationNumber d50=roundedSpace Case 1 d9=leftOffset d83=rightOffset d78=iterationNumber d80=roundedSpace End Select
The case statement continues for further variables. My question is how to set up the top code to run as a subroutine for each variable in the case statement. I've seen some "Sub Main" type codes in google and forum searches, but the examples I've found quickly go over my head in complexity.
I am very much a beginner in iLogic coding and have no experience using visual basic. I hoping to find an explanation of HOW to write the program I need rather than just have someone write it for me (although that would be a big help too).
Thank you!
Solved! Go to Solution.