On Wed, Nov 23, 2016 at 11:18 AM Wesley Keeling <[email protected]>
wrote:

> I do have one last question since each polly command takes in multiple
> commands to settAttr
> [subdivisionsAxis, subdivisionsHeight, subdivisionsWidth, etc] It won't
> really help me to settAttr in a generic way.
>
> The lambda (if I understand it correctly):
>

It isnt a lambda. A lambda looks like this:

fn = lambda x: x+1

It is just a reference to a function (callable) object


> *fn = self.primitives[primitiveType] xform, shape = fn() fn(shape, e=True,
> sx=30)*
>
> Fits perfectly for what I need, just one last question. How can I set the
> scale property from fn()? I cannot use scale as a flag, it's tossing a error*
> 'No flag name 'scale'.*
>

If not all of those commands support a "scale" argument, then you won't be
able to do it that way. You would have to have another way to switch on the
type to return a function that can apply a scale.

Do you just mean scaling via cmds.xform() ? That should work with any of
the objects.


>
> If it's also not too much to ask can I confirm the logic of those lines?
> I am assigning fn to the dictonary and then calling it as a function with
> the properties of Xform on the 'shape'?
>

You are assigning fn to be a reference to a function, which was stored as a
value in your dictionary. You looked up that value by a primitive type.
You then call that callable, which is stored in the variable "fn", and
split the two item tuple that is returned into two variables. "xform"
contains the transform of the new object, and "shape" contains the shape.
Then you call that callable stored in "fn" again, passing it the shape and
some other arguments.


>
> Thanks again man!
>
>
> On Tue, Nov 22, 2016 at 1:54 PM, Justin Israel <[email protected]>
> wrote:
>
>
>
> On Wed, Nov 23, 2016 at 10:21 AM Wesley Keeling <[email protected]>
> wrote:
>
> Justin to the rescue again! Thanks so much man!
>
>
> No worries!
>
>
>
> On Tue, Nov 22, 2016 at 12:44 PM, Justin Israel <[email protected]>
> wrote:
>
>
>
> On Wed, Nov 23, 2016 at 8:59 AM I73 <[email protected]> wrote:
>
> Hey I am trying to create a method to handle creating new objects, with a
> dictionary
>
> class GenerationProperties():
>     primitives = {
>         'sphere' : cmds.polySphere,
>         'geosphere' : cmds.polyPrimitive,
>         'cube' : cmds.polyCube,
>         'cylinder' : cmds.polyCylinder,
>         'cone' : cmds.polyCone,
>         'plane' : cmds.polyPlane,
>         'torus' : cmds.polyTorus,
>         'prism' : cmds.polyPrism,
>         'pyramid' : cmds.polyPyramid,
>         'pipe' : cmds.polyPipe,
>     }
>
>
>     def CreatePrimitive(self, primitiveType, subdivisionsX = 1,
> subdivisionsY = 1):
>         prim = self.primitives[primitiveType]()
>         #how can I refrence prim to change it's subdivisions after I
> created?
>         # cmds.'Type?'(prim, subdivisionsX, subdivisionsY)
>
>
>
> The problem that I am having is I don't know how I can use
> cmds.poly'Type'() as a generic (cast) to change the subdivisions or edit
> after I create the primitive.
>
>
> Any help would be appreciated!
>
>
> I could see two different ways. Since you already have the proper command
> mapped, you can just use it in edit mode:
>
> fn = self.primitives[primitiveType]
> xform, shape = fn()
> fn(shape, e=True, sx=30)
>
> ​
>
> or
>
> prim = self.primitives[primitiveType]
> cmds.setAttr("%s.subdivisionHeight" % prim[1], 30)
>
> ​
>
> Justin
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/331d4f46-5bb2-45dd-9b9d-bde6b7caff91%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/331d4f46-5bb2-45dd-9b9d-bde6b7caff91%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python_inside_maya/xkXvEPPRrzg/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0-txhFXCABd6-W2whij-cffCu5uTBGk5zST%3DsBHXQk5w%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0-txhFXCABd6-W2whij-cffCu5uTBGk5zST%3DsBHXQk5w%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
>
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAAD4CW6%3DiavvS89wGMCVV%3DGt0Fof02epvXcnBsKGOKc7M_Dixg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAAD4CW6%3DiavvS89wGMCVV%3DGt0Fof02epvXcnBsKGOKc7M_Dixg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python_inside_maya/xkXvEPPRrzg/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
>
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3Y1CLUVzss-Jts2kjQ74FjtB%2BAvV8zm6hiK%3D6poW%3D3jg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3Y1CLUVzss-Jts2kjQ74FjtB%2BAvV8zm6hiK%3D6poW%3D3jg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
>
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAAD4CW6%3DoLAD1C8paThXvq1M8PyhFnX_ccpooBLqMPNB3e9Viw%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAAD4CW6%3DoLAD1C8paThXvq1M8PyhFnX_ccpooBLqMPNB3e9Viw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3F-JsXtbcwJQwARnYz7i_sZ36G%2BPGD6UwW_gFy0SwpGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to