Jump to content

Python Generator - How to assign a field object to a deformer


Recommended Posts

Hi all.

I am new to python and I'm looking for help with assigning a field object to a deformer's falloff within a Python Generator.

So for example I set up the objects like this:

myParentNull = c4d.BaseObject(c4d.Onull)
myFieldObj = c4d.BaseObject(c4d.Flinear)
myModObj = c4d.BaseObject(1021280) #1021280 = Squash And Stretch Deform Object
myFieldObj.InsertUnder(myParentNull)

... I then hoped that this would achieve what I was after, but it looks like this isn't the way to assign the field object (it doesn't work)

myModObj[c4d.FIELDS] = myFieldObj

Can anyone help?

Many thanks,
Jamie
www.moGRR.co.uk

Link to post
1 hour ago, Havealot said:

Try asking at developers.MAXON.net. The guys there are very helpful. 

Awesome portfolio btw. 🙂

 

Thanks Havealot. I asked on the MAXON site too, but as I'm new to Python I wasn't sure where would be the best place to ask. I do have someone there that is currently helping me (I need to use FieldLists and FieldLayers). I'm a little closer to solving the issue now with this code:

 

def main():
    myParentNull = c4d.BaseObject(c4d.Onull)

    myDefObj = c4d.BaseObject(1021280) #1021280 = Squash And Stretch Deform Object
    myDefObj.InsertUnder(myParentNull)

    myFieldNull = c4d.BaseObject(c4d.Onull)
    myFieldNull.InsertUnder(myParentNull)

    myFieldObj = c4d.BaseObject(c4d.Flinear)
    myFieldObj.InsertUnder(myFieldNull)

    myFieldLayer = c4d.modules.mograph.FieldLayer(c4d.FLfield)
    myFieldLayer.SetLinkedObject(myFieldObj)

    myFieldList = c4d.FieldList()
    myFieldList.InsertLayer(myFieldLayer)

    return(myParentNull)

However, the Field object is still not being inserted into the Deformer's falloff.

Link to post

For anyone interested, I've resolved this now. I simply forgot to add the last line of code (oops). Here is the Python Generator code that does what I was trying to do:

def main():
    myParentNull = c4d.BaseObject(c4d.Onull)

    myDefObj = c4d.BaseObject(1021280) #1021280 = Squash And Stretch Deform Object
    myDefObj.InsertUnder(myParentNull)

    myFieldNull = c4d.BaseObject(c4d.Onull)
    myFieldNull.InsertUnder(myParentNull)

    myFieldObj = c4d.BaseObject(c4d.Flinear)
    myFieldObj.InsertUnder(myFieldNull)

    myFieldLayer = c4d.modules.mograph.FieldLayer(c4d.FLfield)
    myFieldLayer.SetLinkedObject(myFieldObj)

    myFieldList = c4d.FieldList()
    myFieldList.InsertLayer(myFieldLayer)

    myDefObj[c4d.FIELDS] = myFieldList

    return(myParentNull)

 

 

 

 

 

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...