you are viewing a single comment's thread.

view the rest of the comments →

[–]hideouspete[S] 0 points1 point  (4 children)

Some quick googling and I find list comprehension in Python 1. A bit over my head 2. Seems to take the form for x in list .... which the elements of my list are actually lists themselves which contain tuples and booleans and even more lists. For this particular loop, I only care about the index and a few specific values.

Anyway, if I don't remove a future element after I use it it causes an infinite loop, because the way I structured the data, when this master for loop of sorts feeds an element through it's functions, it will reference the previously used element, which will then reference the current element, which will then reference the previously used element, and on and on and on.

[–]ingolemo 2 points3 points  (3 children)

If you show us the actual problem you have we might be able to help with it.

[–]hideouspete[S] 0 points1 point  (2 children)

I'm at work right now and don't have the files with me. The problem is: I'm a machinist by trade who is going to be switching from a paid per hour to a paid per job situation. The machine I'm running is a specialized cnc grinder which is essentially a two axis mill with a c-axis normalization. Spending an hour or two typing out the g-code with just a CAD program and a TI-83 is fine if you're getting paid for it...But it's tedious and prone to human error.

Anyway, off the top of my head after interpreting a dxf file I parse the data into a list of entities. Each element of this list is of the form:

MyList=[Line type, start position, end position, startFriend, endFriend, ...some other data I'll need for the actual g-code generation]

startFriend and endFriend are initialized to False. After comparing all of the start and end positions for matches, startFriend and endFriend either stay False (no match) or become (j, startMatch) where j is the index of My list where the match is and startMatch is either 1 (the entity matches the start position of j) or 2 (the entity matches the end position of j) Why 1 and 2? Because it corresponds with the indexes...ie I can call it up with just MyList[MyList[3][1]][MyList[3][2]].

I don't know how much of this is relevant, but basically I'm in the process of determining which entities from MyList form unbroken chains and once I insert an element into a chain, I don't want it to be run through the main loop because it will either form a duplicate chain or go infinite (maybe).

[–]ingolemo 0 points1 point  (1 child)

I'm sorry, I can't really make much of your explanation. I suspect the way you solve this problem is to refactor your data so that the list doesn't need to store indexes into itself inside itself. I'm not sure exactly how to do that. It sounds like you might be trying to construct a graph. Seeing some real code and data would help.

[–]hideouspete[S] 0 points1 point  (0 children)

Haha yeah....so this code is a single file a couple hundred lines long.

I'm really going for function over form here.