Re: [Maya-Python] Getting the original shader assignment

2016-10-06 Thread Justin Israel
On Fri, Oct 7, 2016 at 2:08 PM likage  wrote:

> Was wondering if anyone has any good ways for approaching this problem of
> mine...
>
>
> I have a few rigs in which it is a reference. I am trying to do some
> shader-assignment that targets for a certain name in these rigs.
>
> In my UI, if the user selects a certain color in the combobox, it will
> create a new shader and assign to the geos within that rig(s). And if it
> selects the first index of the combobox which is a blank, it will reassign
> those geos back to shaders that it was initially assigned.
>
>
> For example, I have a test_geo (this is a reference) and it comes with a
> "test_geoShader (lambert)". If I select any other color, the connect
> between the test_geo and test_geoShader will be disconnected and it will be
> assigned with a new shader, eg. newShader (lambert) If I select the
> 'blanked' option, it will disconnect test_geo with the new shader and
> assigned back to test_geoShader
>
>
> However, my code (pls see below) only works on the first try to get the
> original assignment.. Meaning to say if I open my UI the first time, did
> some new shader assignments, close and reopen my UI, it will pick up the
> current assignment it has as the original assignment..
>
>
> Any suggestions in approaching this? And is it possible to do so without
> creating any new files (json etc..) to store the data?
>
Well the fact of the matter is that you would have to persist this
information somewhere, right? There are a ton of places to store this
information, but it also depends on whether you need this persistent to
outlive the current Maya session?

global dictionary in your module
optionVars
files (json, ...)
custom attribute on the node to store the original value

The last one could be useful, because it would obviously be stored directly
on the node in which you are considering. And you could check to see if the
custom attribute exists to know whether you have ever applied a change with
your UI.

>
> def get_orig_shader(self, nodes_list):
> orig_shader_dict = {}
> for node_name in nodes_list:
> node_shapes = get_shape(node_name)
> for node in node_shapes:
> if "defaultPtx" in node:
> shading_grps = cmds.listConnections(node, type=
> 'shadingEngine')
> shaders = cmds.ls(cmds.listConnections(shading_grps),
> materials=1)
> orig_shader_dict[node] = shaders[0]
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/785548cf-e276-433b-aaf8-6e8462a295a4%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1%3DWTwtXc9Tv19p6kZ61bHt8w7KrS_KXLQ3AYb9ySSJqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Getting the original shader assignment

2016-10-06 Thread likage


Was wondering if anyone has any good ways for approaching this problem of 
mine...


I have a few rigs in which it is a reference. I am trying to do some 
shader-assignment that targets for a certain name in these rigs.

In my UI, if the user selects a certain color in the combobox, it will 
create a new shader and assign to the geos within that rig(s). And if it 
selects the first index of the combobox which is a blank, it will reassign 
those geos back to shaders that it was initially assigned.


For example, I have a test_geo (this is a reference) and it comes with a 
"test_geoShader (lambert)". If I select any other color, the connect 
between the test_geo and test_geoShader will be disconnected and it will be 
assigned with a new shader, eg. newShader (lambert) If I select the 
'blanked' option, it will disconnect test_geo with the new shader and 
assigned back to test_geoShader


However, my code (pls see below) only works on the first try to get the 
original assignment.. Meaning to say if I open my UI the first time, did 
some new shader assignments, close and reopen my UI, it will pick up the 
current assignment it has as the original assignment..


Any suggestions in approaching this? And is it possible to do so without 
creating any new files (json etc..) to store the data?


def get_orig_shader(self, nodes_list):
orig_shader_dict = {}
for node_name in nodes_list:
node_shapes = get_shape(node_name)
for node in node_shapes:
if "defaultPtx" in node:
shading_grps = cmds.listConnections(node, type=
'shadingEngine')
shaders = cmds.ls(cmds.listConnections(shading_grps), 
materials=1)
orig_shader_dict[node] = shaders[0]


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/785548cf-e276-433b-aaf8-6e8462a295a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: workspaceControl in 2017

2016-10-06 Thread Marcus Ottosson
That should be a problem

Oh! Haha, I meant to say “should*n’t*“. How rude and sarcastic it made me
sound just now. Sorry about that. :)
​

On 6 October 2016 at 19:28, Andrew Hazelden 
wrote:

> Hi MarkJ.
>
> I wanted to comment about your minimum width setting in the code sample
> you provided. According to the workspaceControl documentation
> 
> that should be a boolean value so your code that sets the value to "mw=355"
> wouldn't function as expected. You should probably add an entry to the
> initial workspaceControl code of "minimumWidth=True", at the same time you
> define the "initialWidth=355, " setting to get the results you are after.
>
> *minimumWidth*(mw) boolean create query edit
> Sets the minimum width of control to the initial width. This should be
> used along with initial width flag.
>
> Regards,
> Andrew Hazelden
>
>
> On Thursday, 6 October 2016 06:24:36 UTC-3, MarkJ wrote:
>>
>> Hi all,
>>
>> I'm trying to switch some of our base toolset so that the main UI (cmds
>> built) now docks correctly in the same tab as the channelBox rather than
>> docking to the right side of the main Maya UI. The ChannelBox is now a
>> workspaceControl so I havce to call the UI through that as below, it's a
>> bit of a pain to switch the ui over but I hate the fact that the right
>> dockControl space is now the entire length of the Maya UI, and outside of
>> everything else.
>>
>> So I did the following to make the UI tab into the workspace of the
>> channelBox:
>>
>>
>>
>> element=mel.eval('getUIComponentDockControl("Channel Box / Layer
>> Editor", false);')
>> windowcall='myUIFunc'
>> cmds.workspaceControl(animUI.workspaceCnt, label="Red9_Animation",
>>   uiScript=windowcall,
>>   tabToControl=(element, -1),
>>   initialWidth=355,
>>   initialHeight=720,
>>   retain=False,
>>   loadImmediately=False)
>>
>> cmds.workspaceControl(animUI.workspaceCnt, e=True,vis=True)  # ensure we
>> set visible
>> cmds.workspaceControl(animUI.workspaceCnt, e=True, mw=355)  # set
>> minimumWidth
>> cmds.workspaceControl(animUI.workspaceCnt, e=True,  r=True)  # raise
>>
>> Now that all works but I'll be damned if I can find a way to control and
>> lock the width of this UI. If I go to the modelling tab and then my tab the
>> ui is the correct width, presumably because I set the minimumWidth flag.
>>
>> However, if I go to the attributeEditor tab, then mine the ui remains the
>> width of the attributeEditor. There's width query flags in the
>> workspaceControl, but no edit.
>>
>> So the question is, how the hell do you set a base width that is
>> respected for these?
>>
>> cheers
>>
>> Mark
>>
>>
>>
>> -
>> Mark Jackson
>> CEO / Technical Director
>> red9consultancy.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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/3ddf5aae-4d35-4e1b-8762-
> 15b29ccc1312%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Marcus Ottosson*
konstrukt...@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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOABrd_bbujBrKDLzi07fxj6CnGoTBYWTaevHgGj%3DE%2BA8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: workspaceControl in 2017

2016-10-06 Thread Andrew Hazelden
Hi MarkJ.

I wanted to comment about your minimum width setting in the code sample you 
provided. According to the workspaceControl documentation 

 
that should be a boolean value so your code that sets the value to "mw=355" 
wouldn't function as expected. You should probably add an entry to the 
initial workspaceControl code of "minimumWidth=True", at the same time you 
define the "initialWidth=355, " setting to get the results you are after.

*minimumWidth*(mw) boolean create query edit
Sets the minimum width of control to the initial width. This should be used 
along with initial width flag. 

Regards,
Andrew Hazelden

On Thursday, 6 October 2016 06:24:36 UTC-3, MarkJ wrote:
>
> Hi all,
>
> I'm trying to switch some of our base toolset so that the main UI (cmds 
> built) now docks correctly in the same tab as the channelBox rather than 
> docking to the right side of the main Maya UI. The ChannelBox is now a 
> workspaceControl so I havce to call the UI through that as below, it's a 
> bit of a pain to switch the ui over but I hate the fact that the right 
> dockControl space is now the entire length of the Maya UI, and outside of 
> everything else.
>
> So I did the following to make the UI tab into the workspace of the 
> channelBox:
>
>
>
> element=mel.eval('getUIComponentDockControl("Channel Box / Layer Editor", 
> false);')  
> windowcall='myUIFunc'
> cmds.workspaceControl(animUI.workspaceCnt, label="Red9_Animation", 
>   uiScript=windowcall, 
>   tabToControl=(element, -1), 
>   initialWidth=355, 
>   initialHeight=720,
>   retain=False,
>   loadImmediately=False)  
>
> cmds.workspaceControl(animUI.workspaceCnt, e=True,vis=True)  # ensure we 
> set visible
> cmds.workspaceControl(animUI.workspaceCnt, e=True, mw=355)  # set 
> minimumWidth
> cmds.workspaceControl(animUI.workspaceCnt, e=True,  r=True)  # raise
>
> Now that all works but I'll be damned if I can find a way to control and 
> lock the width of this UI. If I go to the modelling tab and then my tab the 
> ui is the correct width, presumably because I set the minimumWidth flag. 
>
> However, if I go to the attributeEditor tab, then mine the ui remains the 
> width of the attributeEditor. There's width query flags in the 
> workspaceControl, but no edit.
>
> So the question is, how the hell do you set a base width that is respected 
> for these?
>
> cheers
>
> Mark
>
>
>
> -
> Mark Jackson
> CEO / Technical Director
> red9consultancy.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/3ddf5aae-4d35-4e1b-8762-15b29ccc1312%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] workspaceControl in 2017

2016-10-06 Thread Marcus Ottosson
managing PySide builds

That should be a problem, Maya ships with PySide since quite a while back.
​

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBMM8fLwFQNRDEkYmrt%2BZqin0vsCO3iUs71b1_8wMAbow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] workspaceControl in 2017

2016-10-06 Thread Mark Jackson
Unfortunately I'm trying to keep this UI in cmds so that for the openSource
build of the tools I don't have to get into managing PySide builds, that
said I suspect this may only be fixable in QT..

On 6 October 2016 at 12:14, Justin Israel  wrote:

>
>
> On Thu, 6 Oct 2016, 10:24 PM Mark Jackson  wrote:
>
>> Hi all,
>>
>> I'm trying to switch some of our base toolset so that the main UI (cmds
>> built) now docks correctly in the same tab as the channelBox rather than
>> docking to the right side of the main Maya UI. The ChannelBox is now a
>> workspaceControl so I havce to call the UI through that as below, it's a
>> bit of a pain to switch the ui over but I hate the fact that the right
>> dockControl space is now the entire length of the Maya UI, and outside of
>> everything else.
>>
>> So I did the following to make the UI tab into the workspace of the
>> channelBox:
>>
>>
>>
>> element=mel.eval('getUIComponentDockControl("Channel Box / Layer
>> Editor", false);')
>> windowcall='myUIFunc'
>> cmds.workspaceControl(animUI.workspaceCnt, label="Red9_Animation",
>>   uiScript=windowcall,
>>   tabToControl=(element, -1),
>>   initialWidth=355,
>>   initialHeight=720,
>>   retain=False,
>>   loadImmediately=False)
>>
>> cmds.workspaceControl(animUI.workspaceCnt, e=True,vis=True)  # ensure we
>> set visible
>> cmds.workspaceControl(animUI.workspaceCnt, e=True, mw=355)  # set
>> minimumWidth
>> cmds.workspaceControl(animUI.workspaceCnt, e=True,  r=True)  # raise
>>
>> Now that all works but I'll be damned if I can find a way to control and
>> lock the width of this UI. If I go to the modelling tab and then my tab the
>> ui is the correct width, presumably because I set the minimumWidth flag.
>>
>> However, if I go to the attributeEditor tab, then mine the ui remains the
>> width of the attributeEditor. There's width query flags in the
>> workspaceControl, but no edit.
>>
>> So the question is, how the hell do you set a base width that is
>> respected for these?
>>
>
> I haven't seen Maya 2017 yet so I don't know if the details of what has
> changed. But I just recently needed to integrate a custom editor into the
> tabbed attribute editor dock location, in 2016. I went through the Qt
> route, which gave me direct communication with the Qdockwidgets and ability
> to respond to events and signals. And the width is controlled via the size
> hints of the docked child widget. This meant I didn't need to deal with the
> limited Maya cmds wrappers.
>
> Not sure if this info helps but thought I would share.
>
>
>> cheers
>>
>> Mark
>>
>>
>>
>> -
>> Mark Jackson
>> CEO / Technical Director
>> red9consultancy.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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/python_inside_maya/CAGQH2FHLSBZcEEF6jdf%2BBJht-
>> 3rXGAGjBeo0hNYKcuUwuvczuQ%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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/CAPGFgA2S3oQxPPoDFkV-
> 4eZxFq8BLLJniCS3zZ3NAviQfK1vKw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-
Mark Jackson
CEO / Technical Director
red9consultancy.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAGQH2FFeVm9scnxEUECz6GacD3H-arOeQXKJOSnh5wTyowgo9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] workspaceControl in 2017

2016-10-06 Thread Justin Israel
On Thu, 6 Oct 2016, 10:24 PM Mark Jackson  wrote:

> Hi all,
>
> I'm trying to switch some of our base toolset so that the main UI (cmds
> built) now docks correctly in the same tab as the channelBox rather than
> docking to the right side of the main Maya UI. The ChannelBox is now a
> workspaceControl so I havce to call the UI through that as below, it's a
> bit of a pain to switch the ui over but I hate the fact that the right
> dockControl space is now the entire length of the Maya UI, and outside of
> everything else.
>
> So I did the following to make the UI tab into the workspace of the
> channelBox:
>
>
>
> element=mel.eval('getUIComponentDockControl("Channel Box / Layer Editor",
> false);')
> windowcall='myUIFunc'
> cmds.workspaceControl(animUI.workspaceCnt, label="Red9_Animation",
>   uiScript=windowcall,
>   tabToControl=(element, -1),
>   initialWidth=355,
>   initialHeight=720,
>   retain=False,
>   loadImmediately=False)
>
> cmds.workspaceControl(animUI.workspaceCnt, e=True,vis=True)  # ensure we
> set visible
> cmds.workspaceControl(animUI.workspaceCnt, e=True, mw=355)  # set
> minimumWidth
> cmds.workspaceControl(animUI.workspaceCnt, e=True,  r=True)  # raise
>
> Now that all works but I'll be damned if I can find a way to control and
> lock the width of this UI. If I go to the modelling tab and then my tab the
> ui is the correct width, presumably because I set the minimumWidth flag.
>
> However, if I go to the attributeEditor tab, then mine the ui remains the
> width of the attributeEditor. There's width query flags in the
> workspaceControl, but no edit.
>
> So the question is, how the hell do you set a base width that is respected
> for these?
>

I haven't seen Maya 2017 yet so I don't know if the details of what has
changed. But I just recently needed to integrate a custom editor into the
tabbed attribute editor dock location, in 2016. I went through the Qt
route, which gave me direct communication with the Qdockwidgets and ability
to respond to events and signals. And the width is controlled via the size
hints of the docked child widget. This meant I didn't need to deal with the
limited Maya cmds wrappers.

Not sure if this info helps but thought I would share.


> cheers
>
> Mark
>
>
>
> -
> Mark Jackson
> CEO / Technical Director
> red9consultancy.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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAGQH2FHLSBZcEEF6jdf%2BBJht-3rXGAGjBeo0hNYKcuUwuvczuQ%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2S3oQxPPoDFkV-4eZxFq8BLLJniCS3zZ3NAviQfK1vKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: [python] which library using to read / write huge amount of data

2016-10-06 Thread Marcus Ottosson
Cool :)

About reading in a file, a little bit at a time, it’s not as difficult as
it seems.

f = open("100gb.json")

At this point, you’ve opened a file of an imaginary 100 gigabytes. What is
the effect on memory? 0. Nada.

Now, if you were to this..

data = f.read()

You’d be in trouble.

Now you’ve told Python (and the OS) to go out there and bring back the
entire contents of this file and put it in your variable data. That’s no
good.

But there are other ways of reading from a file.

first_line = next(f)

Bam, you’ve opened a huge file, read the first line and stopped. No more
data is read, memory is barely affected.

You can iterate this too.

for line in f:
  print(line)

It will read one line at a time, print it and throw the data away. Memory
is barely affected.

The thing about various file formats, is that some of them can’t be read
like this. Some of them won’t make sense until you’ve read the entire file.

For example, consider JSON.

{
  "key": "value"}

That first line is meaningless. The second line too. For this file to make
sense, you will need to read the entire file.

Some formats, including a variation of JSON, support “streaming”, which is
what we did up there. So if you’re looking to conserve memory, you’ll have
to add this criteria to your desired file format.

ps. Don’t forget to close the file, or use a context manager.

f.close()

​

On 6 October 2016 at 10:13, fruity  wrote:

> actually, the file would be split into 2 parts : the first one would be
> the infos that i want the user to be able to modify (a couple of lines),
> the second one would be a text of n lines (n being a number of vertices for
> a mesh, for instance), that the user will definetly not modify. So you're
> right, maybe i should split it into 2 files, the first in json or similar,
> the second encoded..
> For the memory leak, yes, i did experience something similar, during my
> last project (yes, in rigging too, it was nothing but fun on this project
> =p ), but with in-house tools. So i've seen it, but didn't do it myself.
> But that's why i'm concerned about that. And by memory leak, i'm also
> talking about memory management. For instance, you work on super heavy sets
> (like really super heavy sets ;-), and you want to load some datas
> attached to this set. By default, you'll have to load the entire data file,
> which will result in a huge consommation of RAM, and ultimately, probably a
> crash because of a lack of memory. So it wouldn't be a memory leak so to
> speak, but something that you'd have to handle by reading your file chunk
> after chunk, and flush the memory after each iteration. I'm not sure any
> module would do that automatically, though.
> I'll think at my problem differently, and try to split it into 2 parts,
> that seems so obvious now you mentionned it ! Thanks !
>
>
> Le jeudi 6 octobre 2016 10:29:18 UTC+2, Marcus Ottosson a écrit :
>>
>> cPickle looks great
>>
>> If you want it to be human readable, you can’t encrypt, compress or
>> otherwise obfuscate it, so both pickling and zlib is out. But think about
>> that for a second. If you are talking about multi-megabyte/gigabytes worth
>> of data, the mere quantity would make it uneditable regardless of the
>> format.
>>
>> The part that i’m not sure of is the memory management when working with
>> huge chunks of data, and i’m even not comfortable at how to mesure and
>> control it.
>>
>> I’m not sure why you would worry about that, unless you’ve experienced
>> some issues already? So long as you read the file into a variable, and that
>> variable isn’t kept around globally, then garbage collection would handle
>> this for you no matter which format you choose.
>>
>> To get a memory leak, you’d really have to try.
>>
>> import json
>>
>> leak = list()
>> def read_file(fname):
>>   with open(fname) as f:
>> data = json.load(f)
>> leak.append(data)  # builds up over time
>>
>> ​
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/211afd52-15e9-4b4f-81bb-
> 05d11fb702b4%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Marcus Ottosson*
konstrukt...@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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAC7MZiDpKSWcUqGOqeS

[Maya-Python] workspaceControl in 2017

2016-10-06 Thread Mark Jackson
Hi all,

I'm trying to switch some of our base toolset so that the main UI (cmds
built) now docks correctly in the same tab as the channelBox rather than
docking to the right side of the main Maya UI. The ChannelBox is now a
workspaceControl so I havce to call the UI through that as below, it's a
bit of a pain to switch the ui over but I hate the fact that the right
dockControl space is now the entire length of the Maya UI, and outside of
everything else.

So I did the following to make the UI tab into the workspace of the
channelBox:



element=mel.eval('getUIComponentDockControl("Channel Box / Layer Editor",
false);')
windowcall='myUIFunc'
cmds.workspaceControl(animUI.workspaceCnt, label="Red9_Animation",
  uiScript=windowcall,
  tabToControl=(element, -1),
  initialWidth=355,
  initialHeight=720,
  retain=False,
  loadImmediately=False)

cmds.workspaceControl(animUI.workspaceCnt, e=True,vis=True)  # ensure we
set visible
cmds.workspaceControl(animUI.workspaceCnt, e=True, mw=355)  # set
minimumWidth
cmds.workspaceControl(animUI.workspaceCnt, e=True,  r=True)  # raise

Now that all works but I'll be damned if I can find a way to control and
lock the width of this UI. If I go to the modelling tab and then my tab the
ui is the correct width, presumably because I set the minimumWidth flag.

However, if I go to the attributeEditor tab, then mine the ui remains the
width of the attributeEditor. There's width query flags in the
workspaceControl, but no edit.

So the question is, how the hell do you set a base width that is respected
for these?

cheers

Mark



-
Mark Jackson
CEO / Technical Director
red9consultancy.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAGQH2FHLSBZcEEF6jdf%2BBJht-3rXGAGjBeo0hNYKcuUwuvczuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: [python] which library using to read / write huge amount of data

2016-10-06 Thread fruity
actually, the file would be split into 2 parts : the first one would be the 
infos that i want the user to be able to modify (a couple of lines), the 
second one would be a text of n lines (n being a number of vertices for a 
mesh, for instance), that the user will definetly not modify. So you're 
right, maybe i should split it into 2 files, the first in json or similar, 
the second encoded..
For the memory leak, yes, i did experience something similar, during my 
last project (yes, in rigging too, it was nothing but fun on this project 
=p ), but with in-house tools. So i've seen it, but didn't do it myself. 
But that's why i'm concerned about that. And by memory leak, i'm also 
talking about memory management. For instance, you work on super heavy sets 
(like really super heavy sets ;-), and you want to load some datas 
attached to this set. By default, you'll have to load the entire data file, 
which will result in a huge consommation of RAM, and ultimately, probably a 
crash because of a lack of memory. So it wouldn't be a memory leak so to 
speak, but something that you'd have to handle by reading your file chunk 
after chunk, and flush the memory after each iteration. I'm not sure any 
module would do that automatically, though.
I'll think at my problem differently, and try to split it into 2 parts, 
that seems so obvious now you mentionned it ! Thanks !


Le jeudi 6 octobre 2016 10:29:18 UTC+2, Marcus Ottosson a écrit :
>
> cPickle looks great
>
> If you want it to be human readable, you can’t encrypt, compress or 
> otherwise obfuscate it, so both pickling and zlib is out. But think about 
> that for a second. If you are talking about multi-megabyte/gigabytes worth 
> of data, the mere quantity would make it uneditable regardless of the 
> format.
>
> The part that i’m not sure of is the memory management when working with 
> huge chunks of data, and i’m even not comfortable at how to mesure and 
> control it.
>
> I’m not sure why you would worry about that, unless you’ve experienced 
> some issues already? So long as you read the file into a variable, and that 
> variable isn’t kept around globally, then garbage collection would handle 
> this for you no matter which format you choose.
>
> To get a memory leak, you’d really have to try.
>
> import json
>
> leak = list()
> def read_file(fname):
>   with open(fname) as f:
> data = json.load(f)
> leak.append(data)  # builds up over time
>
> ​
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/211afd52-15e9-4b4f-81bb-05d11fb702b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Python screenshot

2016-10-06 Thread Marcus Ottosson
There’s always trusty old Qt.

# From within Mayaimport osfrom PySide.QtGui import QPixmap, QApplication

app = QApplication.instance()
screenshot = QPixmap.grabWindow(app.desktop().winId())
screenshot.save(os.path.expanduser("~/screenshot.jpg"), "jpg")

It can do regions too.
​

On 6 October 2016 at 10:00, Arjun Thekkummadathil <3dar...@gmail.com> wrote:

> Hi
>Anyone knows any existing library or quick method to do a screenshot
> using python. I should be able to select a region to be screen grabbed. Am
> looking for an option on windows.
>
> thanks
>
> Arjun
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/CAJrOGy9tEcVdFsyQsn8OvRAiC6bXs
> 854nDjFCdS_C2qGb-140A%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Marcus Ottosson*
konstrukt...@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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAEpePwGgqpnyhzuTYk8pQup-E%3DdF4JZrEMP0K0tPHJ3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Python screenshot

2016-10-06 Thread Arjun Thekkummadathil
Hi
   Anyone knows any existing library or quick method to do a screenshot
using python. I should be able to select a region to be screen grabbed. Am
looking for an option on windows.

thanks

Arjun

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAJrOGy9tEcVdFsyQsn8OvRAiC6bXs854nDjFCdS_C2qGb-140A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: [python] which library using to read / write huge amount of data

2016-10-06 Thread Marcus Ottosson
cPickle looks great

If you want it to be human readable, you can’t encrypt, compress or
otherwise obfuscate it, so both pickling and zlib is out. But think about
that for a second. If you are talking about multi-megabyte/gigabytes worth
of data, the mere quantity would make it uneditable regardless of the
format.

The part that i’m not sure of is the memory management when working with
huge chunks of data, and i’m even not comfortable at how to mesure and
control it.

I’m not sure why you would worry about that, unless you’ve experienced some
issues already? So long as you read the file into a variable, and that
variable isn’t kept around globally, then garbage collection would handle
this for you no matter which format you choose.

To get a memory leak, you’d really have to try.

import json

leak = list()
def read_file(fname):
  with open(fname) as f:
data = json.load(f)
leak.append(data)  # builds up over time

​

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBrcajZrWjMPad1K5Jkdk%3Dm0xRYqJqC%3DGNkggU-b%3DYfNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: [python] which library using to read / write huge amount of data

2016-10-06 Thread fruity
wow, i can see a lot of knowledge here, thanks a lot ! 
So, to clarify a bit, i already have the working prototype, that's why i'd 
like to optimize it now =] And i didn't mention it, but i'd also like to 
keep it editable out of maya (i.e. i'd go for a human readable encoding). I 
didn't know zlib, but it looks very handy, thanks for the tip ! But as it 
is compressed, i guess i can't export it in a readable way (even if i 
could, i'd loose the whole benefit of using it). However, for other 
purposes, it can be really great, i'll keep that in mind ^^

cPickle looks great as well, and based on your test, Justin. It even looks 
faster than json, i'm surprised it's less used.
So from what i've read here, json seems to be the best option for me (i 
also want something native, so no msgpack or ujson), but still, i guess 
i'll have to run some tests to compare it to raw text with no module. The 
part that i'm not sure of is the memory management when working with huge 
chunks of data, and i'm even not comfortable at how to mesure and control 
it. I assume this comes for free when working with modules, but i'd have to 
handle it if i export my stuff without ?



Le mercredi 5 octobre 2016 10:10:41 UTC+2, fruity a écrit :
>
> Hi there !
>
> I'm working on a skin weight IO tool (or similar), and i was wondering 
> what is the fastest way of reading/writing the datas, mainly between 
> configParser, json, xml and raw text.
> From my researches, it seems that json is the best take (even better if 
> ujson can be installed), but that sounds surprising, as i thought xml was 
> precisely done to handle huge datasets (and xml is also what maya uses to 
> export weights, btw). And finally, i'd like to know if writing raw text, 
> without using any parser, could be faster ? I don't really need to access 
> things line by line, so maybe this could be a fastest solution. But if i go 
> for raw text, then i don't really know how the memory will be handled (for 
> instance, if i have to read a 100 000lines file, does it mean that the 
> entire document needs to be loaded into memory, resulting in some memory 
> leaks or similar issues ? If i use a parser, the memory management will 
> come for free i guess ?)
> Any help will be more than welcome, i'm not familiar with those kind of 
> problems !
>
> Many thanks =]
>
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/bd3b4454-0a8a-4838-9000-aefbb120aa1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.