issue with inserting fieldlayers in r2024
-
hi there,
I'm having a weird issue with fieldlayers in r2024.
I want to add a layer to a fieldlist. In r2023 it worked quite fine. Now I get a reference Error.
But when I print anything, the error is not raised.
In my example I use a python generator, but it seems to happen with a python tag, too.
Or am I using/inserting the fieldlayers wrong?cheers sebastian
python generator :
import c4d def main() -> c4d.BaseObject: obj = c4d.BaseObject(c4d.Ocube) res = c4d.utils.SendModelingCommand( c4d.MCOMMAND_MAKEEDITABLE, [obj], c4d.MODELINGCOMMANDMODE_ALL, doc = doc ) if not res: print("error") else: obj = res[0].GetClone() vertex_tag = obj.MakeVariableTag( c4d.Tvertexmap, len(obj.GetAllPoints()) ) vertex_tag.SetName( "vertex_highlight_reinforce" ) vertex_tag[c4d.ID_TAGFIELD_ENABLE] = 1 fields = vertex_tag[c4d.ID_TAGFIELDS] f_layer_1 = c4d.modules.mograph.FieldLayer( c4d.FLquantize ) fields.InsertLayer( f_layer_1 ) vertex_tag[c4d.ID_TAGFIELDS] = fields #print ("") # with print active, no error will be raised return obj
results in the following error:
ReferenceError: the object 'c4d.modules.mograph.FieldLayer' is not alive -
Hi Sebastian,
In case you're using SendModelingCommand outside from the main thread you should use dummy document instead of active document as mentioned in the corresponding docs and in our Threading Manual.
When one struggles with such an issue usually the first step is to check the code on the main thread (i.e. in the script manager). However, in this case there's something fishy happening when inserting field layer to the field list. I have created a bug report about this issue. Thanks for sharing your experience!
Cheers,
Ilia -
-
hi ilia @i_mazlov,
thaks for the advice about threading and the dummy document and the fishy part.I continued testing the last days and noticed that it seems to work, when i insert a clone of the fieldlayer.
-
Hey thanks for the report, I indeed fix one issue with the InsertLayer but in your case it was another one, sadly there is no workaround for you (except the one you found).
The fix will be provided in the next release.
Cheers,
Maxime.