Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
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
The FIELDS parameter stores a FieldList object. You have to add your field to that field list.
FIELDS
FieldList
fieldList = op[c4d.FIELDS] layer = c4d.modules.mograph.FieldLayer(c4d.FLfield) layer.SetLinkedObject(field) fieldList.InsertLayer(layer) op[c4d.FIELDS] = fieldList c4d.EventAdd()
See FieldList Manual, c4d.FieldList, c4d.modules.mograph.FieldLayer
Thanks for the reply Plugin Student.
Having a FieldList makes sense. I was kind of looking for something along those lines.
I've tried incorporating your code into my python generator and I'm getting this error with the .InsertLayer line: AttributeError: 'NoneType' object has no attribute 'InsertLayer'
Maybe I'm misunderstanding how the fieldlist and layers work? Here is the Python Generator code I am getting that error with:
import c4d #Welcome to the world of Python 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) myFieldList = myDefObj[c4d.FIELDS] myFieldLayer = c4d.modules.mograph.FieldLayer(c4d.FLfield) myFieldLayer.SetLinkedObject(myFieldObj) myFieldList.InsertLayer(myFieldLayer) c4d.EventAdd() return(myParentNull)
Well,
myFieldList = myDefObj[c4d.FIELDS]
seems to return None.
None
I guess you can create a field list and use that list:
myFieldList = c4d.FieldList()
Also, do not call c4d.EventAdd() in a Python Generator.
c4d.EventAdd()
Thanks again Plugin Student.
I wasn't too sure if I should have an EventAdd in a Python Generator or not, so thanks for clearing that up.
So this is the code I now have, but it still isn't successfully adding the FieldList to the Deformer object:
import c4d #Welcome to the world of Python 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)
Oops - I forgot to have the following line:
myDefObj[c4d.FIELDS] = myFieldList
It all works perfectly now. Thanks again for your help @PluginStudent