Hi all,
I’m putting together a minor helper function for establishing a transform hierarchy within Maya but am not yet satisfied with the implementation.
It works like this.
hierarchy_from_string("""\
rig
implementation
geometry
skeleton
interface
controls
preview
""")
Resulting in this.
The idea then is to start making nodes and move them into their home via cmds.parent()
.
But my implementation so far is fairly limited.
So my question to you is, how would you write this?
def hierarchy_from_string(hierarchy):
parents = {}
for line in hierarchy.split("\n"):
if not line:
continue
name = line.strip()
padding = len(line[:-len(name)])
parents[padding] = name
name = cmds.createNode("transform", name=name)
for parent in sorted(parents):
if parent < padding:
cmds.parent(name, parents[parent])
Thanks for chiming in!
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODMBoLY%2Bcc_%3DK58NKmaPt0D%3DBKqdwL%2B%3DRFwLLH2j8831A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b96da911-316a-4815-83e0-d359fe1b6ea9%40googlegroups.com.
On Fri, 16 Sep 2016, 7:15 AM <marcus.ottosson@framestore.com> wrote:Snarky, but thanks for chiming in.Maybe. Maybe not.ÂIt seems to address your 2nd and 3rd points, by asking if you would consider changing the input string format to a style that would give you hierarchy processing for free.Â
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b96da911-316a-4815-83e0-d359fe1b6ea9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0-U9ovtaBUx4tjgB%2Bx55FKmWM_zHdsW2F85UJ%3DAtyFjw%40mail.gmail.com.
Fair enough!
The resulting function is going into a code example that I’m trying to make as readable as possible.
I find the readability of this approach less distracting and less motivated than, say, this.
hierarchy_from_json({
"rig": {
"implementation": {},
"geometry": {},
"skeleton": {},
"interface": {
"controls": {},
"preview": {},
}
}
})
And YAML would require either my tiny example to include it, or for the user to install it.
Apart from that, and the reason I’m here, was that I was interested in seeing how others would approach a string processing challenge of this stature. I expected to find it inspiring and spark ideas with others and myself.
from collections import namedtuple from bisect import bisect_left import pymel.core as pm def hierarchy_from_string(hierarchy): NodeInfo = namedtuple('NodeInfo', 'node indent') nodeInfos = [] for nodeName, currIndent in ((line.strip(' '), len(line) - len(line.lstrip(' ')))
for line in hierarchy.split("\n")
if line.strip()): node = (pm.ls(nodeName)[0] if pm.ls(nodeName) else pm.createNode('transform', name=nodeName)) parentIndex = bisect_left([nodeInfo.indent for nodeInfo in nodeInfos], currIndent) parentNode = (nodeInfos[parentIndex - 1].node if parentIndex - 1 >= 0 else None) nodeInfo = NodeInfo(node=node, indent=currIndent) if parentIndex < len(nodeInfos): nodeInfos[parentIndex] = nodeInfo else: nodeInfos.append(nodeInfo) pm.parent(node, parentNode)
hierarchy_from_string("""\ rig     implementation         geometry         skeleton     interface         controls         preview
foo     bar             baz                   alice             bob """)
for nodeName, currIndent in ((line.strip(), len(line) - len(line.lstrip()))
for line in hierarchy.split("\n") if line.strip()):
Ok, Alok, I had a closer look at your example and the bisect module in Python.
In my example, a dict replaces bisect. The dict is limited, in that once a parent at the same level as an above parent appears, the above parent vanishes from consideration. But in this case, maybe that works to our advantage? Could you tell me about your motivation for using bisect?
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d86fb040-1d59-492d-8b7c-50dc5cf67d96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Marcus,My objective was simple, parenting is the main focus and it should be done  once and only once for each node in the hierarchy. To achieve this, during each iteration the node should have knowledge about his parent just by knowing its position (indent).I did not want complex processing of saving states and whole trees and then lookup up and down. The node should have a place (the tuple list) to look for its parent. It simply asks this question - I have this position, who is my parent. This is typically looking for an insertion point in an array and bisect was a perfect candidate for these requirements.After finding the parent, the node attaches itself to the list replacing the current node at that position so that preceding nodes can find it as a parent when required.Using a dict is a better option just for the reason of O(1) lookup times, but then you should do this lookup only once for each node and not iterate through each key and then deep inside it until some condition is reached. To me, that is a bit complex.
On Fri, Sep 16, 2016 at 8:44 PM, Marcus Ottosson <konstr...@gmail.com> wrote:
Ok, Alok, I had a closer look at your example and the bisect module in Python.
In my example, a dict replaces bisect. The dict is limited, in that once a parent at the same level as an above parent appears, the above parent vanishes from consideration. But in this case, maybe that works to our advantage? Could you tell me about your motivation for using bisect?
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d86fb040-1d59-492d-8b7c-50dc5cf67d96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMTaOkfYe0G_x3JCMxfDwiJzeYeQMyAObKCGuPqA2n7foQ%40mail.gmail.com.
As someone who isn't terribly familiar with bisect, how does bisect achieve this if not by traversing each node in turn and returning the first found, like how the dict is being used currently?> but then you should do this lookup only once for each node and not iterate through each key and then deep inside it until some condition is reached. To me, that is a bit complex.Ah, yes that is true. I did not think of that. Thanks for pointing that out.
On 16 September 2016 at 15:01, Alok Gandhi <alok.ga...@gmail.com> wrote:
Hi Marcus,My objective was simple, parenting is the main focus and it should be done  once and only once for each node in the hierarchy. To achieve this, during each iteration the node should have knowledge about his parent just by knowing its position (indent).I did not want complex processing of saving states and whole trees and then lookup up and down. The node should have a place (the tuple list) to look for its parent. It simply asks this question - I have this position, who is my parent. This is typically looking for an insertion point in an array and bisect was a perfect candidate for these requirements.After finding the parent, the node attaches itself to the list replacing the current node at that position so that preceding nodes can find it as a parent when required.Using a dict is a better option just for the reason of O(1) lookup times, but then you should do this lookup only once for each node and not iterate through each key and then deep inside it until some condition is reached. To me, that is a bit complex.----On Fri, Sep 16, 2016 at 8:44 PM, Marcus Ottosson <konstr...@gmail.com> wrote:Ok, Alok, I had a closer look at your example and the bisect module in Python.--
In my example, a dict replaces bisect. The dict is limited, in that once a parent at the same level as an above parent appears, the above parent vanishes from consideration. But in this case, maybe that works to our advantage? Could you tell me about your motivation for using bisect?
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d86fb040-1d59-492d-8b7c-50dc5cf67d96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMTaOkfYe0G_x3JCMxfDwiJzeYeQMyAObKCGuPqA2n7foQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOD02m%3DbffY2GhNbncgEs0OXp0iYeck_woAg9fATHt2PTA%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d86fb040-1d59-492d-8b7c-50dc5cf67d96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMTaOkfYe0G_x3JCMxfDwiJzeYeQMyAObKCGuPqA2n7foQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOD02m%3DbffY2GhNbncgEs0OXp0iYeck_woAg9fATHt2PTA%40mail.gmail.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMTxrmjYe%2B%3Dt1f8C6AJO3KziSscq%3DYF4eMGQrwv%3DTy13AA%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d86fb040-1d59-492d-8b7c-50dc5cf67d96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMTaOkfYe0G_x3JCMxfDwiJzeYeQMyAObKCGuPqA2n7foQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOD02m%3DbffY2GhNbncgEs0OXp0iYeck_woAg9fATHt2PTA%40mail.gmail.com.
--
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMTxrmjYe%2B%3Dt1f8C6AJO3KziSscq%3DYF4eMGQrwv%3DTy13AA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAL6_5Q-cd7np8pv74FZ%3DK4f_bKZrBpq%3DTis6UEMbsSRxv7AxGw%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODtC8L1BiXxbTOHRH_KwK32ZxRZeo%3DatdrKgdkeThNzRw%40mail.gmail.com.
Coming back to some of the points that Ian raised:  > Readability is a perfectly valid goal to seek but I find maintainability is often overlooked.IMHO more readable code is more maintainable. Readability goes hand in hand with maintainability. In fact, I very much agree that code lasts longer than an author and if you write readable code it will be easier to read and understand for the people after you are gone and are not available to explain why you did what. If by maintainability you meant actually extensibility, then it is a completely different aspect.
1. Integrity - The software should operate in a predictable manner, respond appropriately to exceptional conditions, and clean up nicely during a termination
2. Readability - The intent of the code should be clear
3. Simplicity (has to be justified to be more important than #2)
4. Performance> In driving to a solution avoiding the additional markup (as in my solution or in json/XML) you've likely put yourself (and too often your team after you've left) in a place where you'll need to rewrite the function for future feature requests.If you read my previous posts in this threads, you will see that I clearly mentioned that getting input is an administrative logic. In fact, I provisioned for it and alluded to Marcus about it. Here's what I wrote:
- Right in the beginning, we parse the string in a single line, keeping the administrative logic out from the rest of our business code. You can easily replace this single line with whatever parser you want.
This means that the code that is responsible for creating nodes should not worry itself with how it is getting the data in, JSON or YAML. And the parser, whichever it is, should not worry about what is going to happen to data it outputs. any good architecture should take care of this point. Making components decoupled and flexible. Good architecture does not only apply to huge libraries or big project, it should be given thought to every single small quantum of code, a function and even inside parts of a function. I did not avoid the input data structure, I simply did not work on that part as was not required my Marcus originally. Even then, I separated the code so that in my implementation, nowhere it does rely on whether I choose JSON or YAML or some other markup. If ten years later, somebody wants to use my implementation, with JSON the only change it would require is to change the first line of my code.
On Sat, Sep 17, 2016 at 12:56 AM, Marcus Ottosson <konstr...@gmail.com> wrote:
Thanks Ian!Some notes.- The implementation is up for grabs, but I'd like to keep the interface of the function; that is, passing a single string with indentation for hierarchy.- Performance is not important here, because (1) the function is only being used in example code, where the call itself should fall into the background and (2) creating a hierarchy can safely take a few hundred milliseconds if it means more readable code.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODtC8L1BiXxbTOHRH_KwK32ZxRZeo%3DatdrKgdkeThNzRw%40mail.gmail.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMT8pNLXc4XM7jT4AVQETE37Q9Z0pGYBBBjYZhYbLDHKMQ%40mail.gmail.com.
Is performance something you are concerned with for this process?
Yury
On Sat, Sep 17, 2016 at 5:27 AM Alok Gandhi <alok.ga...@gmail.com> wrote:Coming back to some of the points that Ian raised:  > Readability is a perfectly valid goal to seek but I find maintainability is often overlooked.IMHO more readable code is more maintainable. Readability goes hand in hand with maintainability. In fact, I very much agree that code lasts longer than an author and if you write readable code it will be easier to read and understand for the people after you are gone and are not available to explain why you did what. If by maintainability you meant actually extensibility, then it is a completely different aspect.As an aside, I just recently went to a convention, and in one of the talks the speaker opened with his list of priorities for designing software:Â1. Integrity - The software should operate in a predictable manner, respond appropriately to exceptional conditions, and clean up nicely during a termination
2. Readability - The intent of the code should be clear
3. Simplicity (has to be justified to be more important than #2)
4. PerformanceHe basically yelled at us for 10 minutes about the importance of the first two, and said only when you can prove to me that everything else is addressed, that you should then look at performance. It was a pretty good talk. Â
> In driving to a solution avoiding the additional markup (as in my solution or in json/XML) you've likely put yourself (and too often your team after you've left) in a place where you'll need to rewrite the function for future feature requests.If you read my previous posts in this threads, you will see that I clearly mentioned that getting input is an administrative logic. In fact, I provisioned for it and alluded to Marcus about it. Here's what I wrote:
- Right in the beginning, we parse the string in a single line, keeping the administrative logic out from the rest of our business code. You can easily replace this single line with whatever parser you want.
This means that the code that is responsible for creating nodes should not worry itself with how it is getting the data in, JSON or YAML. And the parser, whichever it is, should not worry about what is going to happen to data it outputs. any good architecture should take care of this point. Making components decoupled and flexible. Good architecture does not only apply to huge libraries or big project, it should be given thought to every single small quantum of code, a function and even inside parts of a function. I did not avoid the input data structure, I simply did not work on that part as was not required my Marcus originally. Even then, I separated the code so that in my implementation, nowhere it does rely on whether I choose JSON or YAML or some other markup. If ten years later, somebody wants to use my implementation, with JSON the only change it would require is to change the first line of my code.
On Sat, Sep 17, 2016 at 12:56 AM, Marcus Ottosson <konstr...@gmail.com> wrote:
Thanks Ian!Some notes.- The implementation is up for grabs, but I'd like to keep the interface of the function; that is, passing a single string with indentation for hierarchy.- Performance is not important here, because (1) the function is only being used in example code, where the call itself should fall into the background and (2) creating a hierarchy can safely take a few hundred milliseconds if it means more readable code.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODtC8L1BiXxbTOHRH_KwK32ZxRZeo%3DatdrKgdkeThNzRw%40mail.gmail.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMT8pNLXc4XM7jT4AVQETE37Q9Z0pGYBBBjYZhYbLDHKMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Sxx%2B2319C1Mv4omtaiEvjppJPrFjVYtgmYxSJvs74AQ%40mail.gmail.com.
Is performance something you are concerned with for this process?
Yury
On Sep 16, 2016 6:16 PM, "Justin Israel" <justin...@gmail.com> wrote:
On Sat, Sep 17, 2016 at 5:27 AM Alok Gandhi <alok.ga...@gmail.com> wrote:Coming back to some of the points that Ian raised:  > Readability is a perfectly valid goal to seek but I find maintainability is often overlooked.IMHO more readable code is more maintainable. Readability goes hand in hand with maintainability. In fact, I very much agree that code lasts longer than an author and if you write readable code it will be easier to read and understand for the people after you are gone and are not available to explain why you did what. If by maintainability you meant actually extensibility, then it is a completely different aspect.As an aside, I just recently went to a convention, and in one of the talks the speaker opened with his list of priorities for designing software:Â1. Integrity - The software should operate in a predictable manner, respond appropriately to exceptional conditions, and clean up nicely during a termination
2. Readability - The intent of the code should be clear
3. Simplicity (has to be justified to be more important than #2)
4. PerformanceHe basically yelled at us for 10 minutes about the importance of the first two, and said only when you can prove to me that everything else is addressed, that you should then look at performance. It was a pretty good talk. Â
> In driving to a solution avoiding the additional markup (as in my solution or in json/XML) you've likely put yourself (and too often your team after you've left) in a place where you'll need to rewrite the function for future feature requests.If you read my previous posts in this threads, you will see that I clearly mentioned that getting input is an administrative logic. In fact, I provisioned for it and alluded to Marcus about it. Here's what I wrote:
- Right in the beginning, we parse the string in a single line, keeping the administrative logic out from the rest of our business code. You can easily replace this single line with whatever parser you want.
This means that the code that is responsible for creating nodes should not worry itself with how it is getting the data in, JSON or YAML. And the parser, whichever it is, should not worry about what is going to happen to data it outputs. any good architecture should take care of this point. Making components decoupled and flexible. Good architecture does not only apply to huge libraries or big project, it should be given thought to every single small quantum of code, a function and even inside parts of a function. I did not avoid the input data structure, I simply did not work on that part as was not required my Marcus originally. Even then, I separated the code so that in my implementation, nowhere it does rely on whether I choose JSON or YAML or some other markup. If ten years later, somebody wants to use my implementation, with JSON the only change it would require is to change the first line of my code.
On Sat, Sep 17, 2016 at 12:56 AM, Marcus Ottosson <konstr...@gmail.com> wrote:
Thanks Ian!Some notes.- The implementation is up for grabs, but I'd like to keep the interface of the function; that is, passing a single string with indentation for hierarchy.- Performance is not important here, because (1) the function is only being used in example code, where the call itself should fall into the background and (2) creating a hierarchy can safely take a few hundred milliseconds if it means more readable code.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODtC8L1BiXxbTOHRH_KwK32ZxRZeo%3DatdrKgdkeThNzRw%40mail.gmail.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMT8pNLXc4XM7jT4AVQETE37Q9Z0pGYBBBjYZhYbLDHKMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Sxx%2B2319C1Mv4omtaiEvjppJPrFjVYtgmYxSJvs74AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGSch6_LnZ%3DXajnQ%3DAZX%2Br2Fwy99rW8WjM4kdUCmKMUpb7jA%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODtC8L1BiXxbTOHRH_KwK32ZxRZeo%3DatdrKgdkeThNzRw%40mail.gmail.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMT8pNLXc4XM7jT4AVQETE37Q9Z0pGYBBBjYZhYbLDHKMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Sxx%2B2319C1Mv4omtaiEvjppJPrFjVYtgmYxSJvs74AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGSch6_LnZ%3DXajnQ%3DAZX%2Br2Fwy99rW8WjM4kdUCmKMUpb7jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0oCXTvXzUC%2BBdkfotstBL%2BJ%3D32tmhXS3rETQxKQ7Q2HQ%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
@Justin: I agree with readability trumping performance, and almost at all times, I follow almost the same tenets. However, in our trade, performance is ever more critical and is becoming important every single day. The entertainment industry is one of the major stakeholders when it comes to demand for processing power. We need that water to look real, 10 million polygon processing, we need that. And on top of that, we work on deadlines, sometimes unreal. When there is a pressing need to process huge amounts of data so that the shot can be approved, we have to do that. And it is at such moments, readability might take a back seat. This by no means is a justification for ignoring readability but rather the state of affairs. There is sometimes a tradeoff involved, sometimes not. You can get the best of both the worlds if you have enough time on your hand.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODtC8L1BiXxbTOHRH_KwK32ZxRZeo%3DatdrKgdkeThNzRw%40mail.gmail.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMT8pNLXc4XM7jT4AVQETE37Q9Z0pGYBBBjYZhYbLDHKMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Sxx%2B2319C1Mv4omtaiEvjppJPrFjVYtgmYxSJvs74AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGSch6_LnZ%3DXajnQ%3DAZX%2Br2Fwy99rW8WjM4kdUCmKMUpb7jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0oCXTvXzUC%2BBdkfotstBL%2BJ%3D32tmhXS3rETQxKQ7Q2HQ%40mail.gmail.com.--
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMSybL5Gp6zch%3DzxgqxMuxGkRHDBVMDWjG0kRg%2BfTJM7DA%40mail.gmail.com.
Also I would like to throw my 2 cents in as someone that develops not as one that writes scripts and tools on a per-show basis to get shots finaled, but as one that works on longer term projects to serve the ongoing pipeline. The advise from that conference might be more applicable to situations like that, where a shot-delivery time frame is not the case. It really just depends on whether your deliverable is a shot, or software.Â
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODtC8L1BiXxbTOHRH_KwK32ZxRZeo%3DatdrKgdkeThNzRw%40mail.gmail.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMT8pNLXc4XM7jT4AVQETE37Q9Z0pGYBBBjYZhYbLDHKMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Sxx%2B2319C1Mv4omtaiEvjppJPrFjVYtgmYxSJvs74AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGSch6_LnZ%3DXajnQ%3DAZX%2Br2Fwy99rW8WjM4kdUCmKMUpb7jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0oCXTvXzUC%2BBdkfotstBL%2BJ%3D32tmhXS3rETQxKQ7Q2HQ%40mail.gmail.com.----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMSybL5Gp6zch%3DzxgqxMuxGkRHDBVMDWjG0kRg%2BfTJM7DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1WcHaU9YQdsan5rJA30tnVxEjMo6BKKb4sc9Rbm_ACBA%40mail.gmail.com.
Also I would like to throw my 2 cents in as someone that develops not as one that writes scripts and tools on a per-show basis to get shots finaled, but as one that works on longer term projects to serve the ongoing pipeline. The advise from that conference might be more applicable to situations like that, where a shot-delivery time frame is not the case. It really just depends on whether your deliverable is a shot, or software.ÂI agree, I am also employed as a Pipeline Engineer and do not have the pressing need to script  for a single shot but rather develop Pipeline Tools and APIs that are consumed by various departments. I can totally understand where you are coming from and it makes complete sense. I started out as an artist (animator, rigger, and generalist) and then a TD and gradually segway into Pipeline. During this journey, I clearly saw my development focus shift from 'just make it work' to 'make it beautiful and readable'.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODtC8L1BiXxbTOHRH_KwK32ZxRZeo%3DatdrKgdkeThNzRw%40mail.gmail.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMT8pNLXc4XM7jT4AVQETE37Q9Z0pGYBBBjYZhYbLDHKMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Sxx%2B2319C1Mv4omtaiEvjppJPrFjVYtgmYxSJvs74AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGSch6_LnZ%3DXajnQ%3DAZX%2Br2Fwy99rW8WjM4kdUCmKMUpb7jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0oCXTvXzUC%2BBdkfotstBL%2BJ%3D32tmhXS3rETQxKQ7Q2HQ%40mail.gmail.com.----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMSybL5Gp6zch%3DzxgqxMuxGkRHDBVMDWjG0kRg%2BfTJM7DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1WcHaU9YQdsan5rJA30tnVxEjMo6BKKb4sc9Rbm_ACBA%40mail.gmail.com.--
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMSF%3Defsqh2CFxPztR_Drb4jwASeJHgwAa1hDk2sRjEwdg%40mail.gmail.com.
Okay. I know this has probably already been figured out, but I can’t help myself with puzzles. Marcus I think you were on to the right idea but just needed to use an OrderedDict with enumerate. here is my stab at it:
import maya.cmds as mc
from collections import OrderedDict
def hierarchy_from_string(hierarchy):
stack = OrderedDict()
for line in hierarchy.split("\n"
):
if not line:
continue
stack[line.strip()]= len(line) -len(line.strip())
node_stack = stack.keys()
for num,(k,v) in enumerate(stack.iteritems()):
tfm = mc.group(n=k,em=True)
if num:
par_stack = node_stack[:num]
par_stack.reverse()
for pp in par_stack:
if stack[pp] < v:
mc.parent(tfm,pp)
break
return stack
hStr = """\
rig
implementation
geometry
skeleton
interface
controls
preview
"""
hierarchy_from_string(hStr)
this will only work in this current example if there aren’t any duplicate names.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODtC8L1BiXxbTOHRH_KwK32ZxRZeo%3DatdrKgdkeThNzRw%40mail.gmail.com.
----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMT8pNLXc4XM7jT4AVQETE37Q9Z0pGYBBBjYZhYbLDHKMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Sxx%2B2319C1Mv4omtaiEvjppJPrFjVYtgmYxSJvs74AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGSch6_LnZ%3DXajnQ%3DAZX%2Br2Fwy99rW8WjM4kdUCmKMUpb7jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0oCXTvXzUC%2BBdkfotstBL%2BJ%3D32tmhXS3rETQxKQ7Q2HQ%40mail.gmail.com.----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMSybL5Gp6zch%3DzxgqxMuxGkRHDBVMDWjG0kRg%2BfTJM7DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1WcHaU9YQdsan5rJA30tnVxEjMo6BKKb4sc9Rbm_ACBA%40mail.gmail.com.----
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMSF%3Defsqh2CFxPztR_Drb4jwASeJHgwAa1hDk2sRjEwdg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2KPoE5g8DxsTeONLAKKbyqhJKkhM%2B6ZKJDaX0gsasr_g%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.