Inventor Engineer-To-Order (Read-Only)
Welcome to Autodesk’s Inventor ETO Forums. Share your knowledge, ask questions, and explore popular Inventor ETO topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Editing items in a list

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
WHassan
645 Views, 3 Replies

Editing items in a list

Hi All,

 

I am tyring to edit a mulitilevel/multiDimensional list but I am getting a compile error.

What I am trying to do is;

   1. to generate a list of parameters for listed children

   2. edit the created list based on a few conditional checks

 

Now the list is created and is working fine, but when I want to edit an item in the list; I am getting the comlie error.

 

Here's what my rule looks like:

 

 

Rule lstPreStdPanels As List

   

    Dim panelCounter As Integer

   

    'loop to create the panel parameters list

    For panelCounter = 1 To intNoStdPanels

 

        lstPreStdPanels = lstPreStdPanels + {{ _

        ":origin", Point(panelCounter * StdPanelLength,0,0), _

        ":xDirection", Vector(0, -1, 0), _

        ":yDirection", Vector(-1, 0, 0), _

        ":panel_length" , StdPanelLength }}

 

    Next

 

    Dim openingCounter As Integer

   

    'Loop through the opening list to check if need changed length

     For openingCounter = 1 To length ( lstOpeningList )

 

        If nth (5, nth( openingCounter , lstOpeningList ) ) = "T" Then

 

            For panelCounter = 1 To intNoStdPanels

 

                'Determine the target panels

                If GetX(Second(nth(panelCounter,lstPreStdPanels)) >50 Then

                   'nth(8, nth( panelCounter, lstPreStdPanels ) ) = 5

 

                End If

 

            Next' panel counter

 

        EndIf' If opening List = T

 

    Next' openings counter

 

End Rule

 

 

I am getting the error on the commented line.

 

I could try to place the conditional checks as the list is generated, but I have more that one conditions which are themself in a loop (in contrast to this sample code).

 

All help is appreciated.

 

Thanking you,

Wajih

 

 

3 REPLIES 3
Message 2 of 4
FarrenYoung
in reply to: WHassan

Hello,

Editing an element of a list is not possible in the intent language as you have shown.  I have worked around this before by creating a replaceItem function which takes a list, an element index, and a newValue and essentially splits the originally list at the index, excluding the item to replace and builds a new list inserting the newValue between the start and end pieces of the two parts of the list.

--Farren

************************************************************************************
If this post helps, please click the "thumbs up" to give kudos
If this post answers your question, please click "Accept as Solution"
************************************************************************************
Message 3 of 4
WHassan
in reply to: FarrenYoung

Could you please post/attach the function/snippet.

 

Trying to accomplish what I had asked has exhausted: I am out ideas.
A fresh perspective would be a re-boot.

 

Thanking you,

 

Wajih

 

 

 

 

Message 4 of 4
Chris_Rogers
in reply to: WHassan

Here is a method that I wrote which replaces an item in a list by index.

 

Method ReplaceItemInList(inputList As List, indexOfItemToReplace As Integer, newValue As Any) As List
     Dim lowerList As List = {}
     Dim upperList As List = {}

     If indexOfItemToReplace > 1 Then
          lowerList = subList(inputList, 1, indexOfItemToReplace -1)
     End If

     If indexOfItemToReplace < length(inputList) Then
          upperList = subList(inputList, indexOfItemToReplace + 1, length(inputList))
     End If

     Return lowerlist + {newValue} + upperList
End Method

 

-Chris Rogers
Inventor Certified Professional
________________________________________________________
If this post helps, please click the "Thumbs up"/"Kudos"
If this post gives the solution, please click "Accept as Solution"

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report