Inventor Engineer-to-Order

Inventor Engineer-to-Order

Reply
Active Contributor
WHassan
Posts: 32
Registered: ‎07-17-2012
Message 1 of 4 (222 Views)
Accepted Solution

Editing items in a list

222 Views, 3 Replies
11-30-2012 08:21 AM

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 + {{ _

        ":smileysurprised:rigin", Point(panelCounter * StdPanelLength,0,0), _

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

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

        ":smileytongue:anel_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

 

 

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

 

Mentor
FarrenYoung
Posts: 264
Registered: ‎07-13-2009
Message 2 of 4 (217 Views)

Re: Editing items in a list

11-30-2012 10:56 AM 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"
************************************************************************************
Active Contributor
WHassan
Posts: 32
Registered: ‎07-17-2012
Message 3 of 4 (211 Views)

Re: Editing items in a list

11-30-2012 11:41 AM 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

 

 

 

 

Active Contributor
Chris_Rogers
Posts: 44
Registered: ‎06-22-2009
Message 4 of 4 (180 Views)

Re: Editing items in a list

12-12-2012 08:40 AM 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"
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Manufacturing Community
The Manufacturing Community provides additional access to tips, tutorials, blogs and networking with peers.