Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations pierreick on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array Question

Status
Not open for further replies.

Twullf

Mechanical
Jan 24, 2012
196
I am attempting to put this code:
Code:
faces2(0) = face1
faceDumbRule2 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces2)

faces3(0) = face3
faceDumbRule3 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces3)

rules4(0) = faceDumbRule2
rules4(1) = faceDumbRule3

Into an loop using arrays, to allow for different sized arrays, or number of faces to be passed. So far it looks like thise:

Code:
      itm2 = checkFace.Length - 1
      msgbox("array length determined")
      For itm1 = 0 To itm2
         msgbox("itm1" & itm1 )
         faces1(0) = checkFace(itm1)
         msgbox("checking face " & itm1 )
         faceDumbRule1 = workPart.scRuleFactory.CreateRuleFaceDumb(faces1)
         rules4(itm1) = faceDumbRule1 
      Next itm1

When itm2 is 0 it works fine, but on any other value it fails. I do not want faces1 to increment I want it to over write every time but I get the following error when I attempt to run the program:

System.IndexOutOfRangeException: Index was outside the bounds of the array.

Checkface is a passed array in tests it contains 3 faces.

faces1(0) is defined as "Dim faces1(0) As Face"

This is code that is intended to be run in Unigraphics environment, but I think the problem is in the VB and not the UG specific code.

any help is appreciated.
 
Replies continue below

Recommended for you

Figured it out, it was the rules4 callout redefined it using itm2 for the size and it worked.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor