Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Creating an Array and Finding the Smallest Value

Status
Not open for further replies.

jzecha

Aerospace
Jan 20, 2016
235
0
0
US
So I am creating an optimized Bounding Box for my company based on some of the other codes I have found and have run into a problem.

I have created multiple bounding boxes and created a Parameter for each boxes' volume.

I have then used those Parameters to try and create an Array that I want to go through and find the smallest volume which would be the smallest Bounding Box.

A couple questions I have:

How do I count the number of Parameters in the Parameter Set?
Every result I have gotten also includes Parameters from the part design itself.

The bigger question, I struggle with the recursive i functions.

Can someone help me out with a way to go through all the parameters and find the smallest value?

Here is the section of code I am working on:
Code:
 Dim strParam10 As StrParam
    Set strParam10 = oParameter.Item("Inertia_Bounding_Box 0 Degrees")
    Dim strParam11 As StrParam
    Set strParam11 = oParameter.Item("Inertia_Bounding_Box 10 Degrees")
    Dim strParam12 As StrParam
    Set strParam12 = oParameter.Item("Inertia_Bounding_Box 20 Degrees")
    Dim strParam13 As StrParam
    Set strParam13 = oParameter.Item("Inertia_Bounding_Box 30 Degrees")
    Dim strParam14 As StrParam
    Set strParam14 = oParameter.Item("Inertia_Bounding_Box 40 Degrees")
    Dim strParam15 As StrParam
    Set strParam15 = oParameter.Item("Inertia_Bounding_Box 50 Degrees")
    Dim strParam16 As StrParam
    Set strParam16 = oParameter.Item("Inertia_Bounding_Box 60 Degrees")
    Dim strParam17 As StrParam
    Set strParam17 = oParameter.Item("Inertia_Bounding_Box 70 Degrees")
    Dim strParam18 As StrParam
    Set strParam18 = oParameter.Item("Inertia_Bounding_Box 80 Degrees")
    
    'MsgBox strParam17.Value
    'MsgBox ("Parameter Count " & oParameter.Count)
    
    'selection1.Search "CATKnowledgeSearch.InternalParameter.Name=*Inertia_Bounding_Box*,all"
    
    Dim BoundingBoxVolumes(8) As Double

    
    SmallestVolume(0) = (strParam10.Value)
    SmallestVolume(1) = (strParam11.Value)
    SmallestVolume(2) = (strParam12.Value)
    SmallestVolume(3) = (strParam13.Value)
    SmallestVolume(4) = (strParam14.Value)
    SmallestVolume(5) = (strParam15.Value)
    SmallestVolume(6) = (strParam16.Value)
    SmallestVolume(7) = (strParam17.Value)
    SmallestVolume(8) = (strParam18.Value)

 
Replies continue below

Recommended for you

No recursion here, just a loop:

Code:
Dim values, value, i, smallest
Set components = CreateObject("System.Collections.ArrayList")
For i=0 to 8
  value = oParameter.Item("Inertia_Bounding_Box " & i*10 & " degrees").Value
  values.Add value
  If IsEmpty(smallest) then
    smallest = value
  ElseIf value < smallest then
    smallest = value
  End If
Next

Post your full code to get advice on "count parameters in Parameter Set" as I don't quite understand what you mean. In most cases Parameters.SubList(feature, false) filters direct parameters related to the feature.
 
Status
Not open for further replies.
Back
Top